PowerShell
PowerShell (native c8y binary)​
Clone the addons repository containing the install script, views and some example templates.
git clone https://github.com/reubenmiller/go-c8y-cli-addons.git "$HOME/.go-c8y-cli"
infoThis repository is not strictly required to run
c8y
however it makes is much more useful as it provides some default views and templates to get the most out ofc8y
. The defaults also show you how you can create your own custom views.Install go-c8y-cli binary
& "$HOME/.go-c8y-cli/install.ps1"
tipIf the following warning is displayed when you try to run the
install.ps1
scriptFile C:\Users\myuser\.go-c8y-cli\install.ps1 cannot be loaded because running scripts is disabled on this system...
Then, open up a new powershell console but set the ExecutionPolicy to remotesigned (or bypass), then you can all the run the script again.
powershell -ExecutionPolicy remotesigned
tipYou can install go-c8y-cli into a shared folder (i.e. C:\tools\cumulocity)
.\install.ps1 -InstallPath C:\tools\cumulocity -UserHome C:\tools\cumulocity -SkipVersionCheck
# Or if you want to edit the global powershell profile for all users, but this requires administrator rights!
.\install.ps1 -InstallPath C:\tools\cumulocity -UserHome C:\tools\cumulocity -SkipVersionCheck -ProfilePath $PROFILE.AllUsersAllHostsVerify that the
c8y
binary is executable and can be found on the command lineGet-Command c8y
OutputCommandType Name Version Source
----------- ---- ------- ------
Application c8y.exe 0.0.0.0 C:\Users\myusername\bin\c8y.exetipTry closing your console and re-opening it so you can be sure that your setup will work next time
Now go to the Getting started section for instructions how to use it
Updating c8y​
If you installed the native c8y binary for powershell using the instructions above, then you can update to the latest version by running:
update-c8y
The update-c8y
function is included in the addons file, $HOME/.go-c8y-cli/shell/c8y.plugin.ps1
, which should have been added to your $PROFILE
file during the installation.
Alternative installation methods​
PSc8y is no longer required to get the best out of go-c8y-cli, so it recommended to use the native c8y binary instead.
Prerequisites​
PowerShell (Core) 7 is available on many operating systems (i.e. Windows, MacOS, Linux). Following the installation guide to install it on your machine.
PSc8y
no longer supports PowerShell 5. Users should install PowerShell 7 (aka pwsh) as it provides a lot of benefits and is also supported on multiple platforms (linux, MacOS and Windows).
If you still don't want to or can't install PowerShell 7 then install the native go-c8y-cli binary.
Installing PSc8y​
Open a PowerShell (pwsh) console
pwsh
Windows UsersIf you get an error regarding the
Execution policy
when installing or importing PSc8y, then you will have to start a new powershell disabling the execution policy.pwsh -ExecutionPolicy bypass
More information on PowerShell's execution policy can be found on the Microsoft website
Install
PSc8y
module from PSGalleryInstall-Module PSc8y -AllowPrerelease -Repository PSGallery -AllowClobber -Scope CurrentUser
Import the module
Import-Module PSc8y
Now go to the Getting started section for instructions how to use it
Updating PSc8y​
Once the PSc8y
PowerShell module has been installed, then it can be updated from within PowerShell itself assuming it was installed as per the "Installing PSc8y" section above.
Update to the latest version
Update-Module PSc8y
Import the updated module
Import-Module PSc8y -Force
Check the new version
Get-Module PSc8y
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 2.0.0 PSc8y {Add-PowershellType, Add-...infoThe version number does not show the pre-release version information.
Downloading using Save-Module​
The PSc8y
module can be downloaded manually using Save-Module
. This has the advantage over Install-Module
as you can control where the module is saved to.
Install-Module
does not allow you to control where the modules are installed. By default the target folder is inside your home directory, however if you have your home folder synced automatically to Microsoft OneDrive then you might run into problems as PSc8y
contains executables (i.e. .exe
files).
Create a folder where you want to store
PSc8y
mkdir ~/PSModules
Download the
PSc8y
Module to the folder~/PSModules
Save-Module -Name PSc8y -AllowPrerelease -Repository PSGallery -Path ~/PSModules
tipSave-Module also accepts
-RequiredVersion
where you can specify an exact version instead of the latest.Import
PSc8y
Import-Module ~/PSModules/PSc8y -Force
tipYou can the
~/PSModules
folder to the$env:PSModulePath
variable so that you can useImport-Module
without having to specify the module location each time.The best way to do this is by adding the following to your PowerShell profile. This can be open by editing the path stored in the
$PROFILE
variable. If the file does not exist, just create it in the specified location.$env:PSModulePath = (Resolve-Path "~/PSModules").Path + ";" + $env:PSModulePath