Just a few days ago, PowerShell Core v6.0 was released for Windows, Linux, and macOS systems. Alongside this release came the release of VMware PowerCLI 10.0.0.78953 which is VMware’s own “PowerShell-like” utility.
In my previous posts (here and here), I covered how to install those on to a macOS 10.13.x “High Sierra” system and a CentOS 7 system. In this post, I am going to show how to install both on to an Ubuntu 17.10 system as this is another common distro which I also use in my environments. Let’s get to it!
Note: If you’re interested in installing this on other Linux distros, please consult the following link.
There is a prerequisite needed before PowerShell can be installed on Ubuntu and that is to install “curl” and then add the PowerShell Core repository (recommended) to your system.
To install curl, enter the following.
sudo apt-get install -y curl
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
curl https://packages.microsoft.com/config/ubuntu/17.04/prod.list | sudo tee /etc/apt/sources.list.d/microsoft.list
sudo apt-get install -y powershell
sudo apt-get upgrade -y powershell
While leveraging the PowerShell Core repository is the recommended installation method, there are alternate methods as well. For more information on that along with uninstallation commands, please see the following link.
Congratulations! You’ve successfully installed PowerShell Core 6.0.1 onto Ubuntu! Next comes the fun stuff for us VMware enthusiasts, installing VMware PowerCLI from the “PSGallery”. Let’s continue!
Since VMware PowerCLI has moved from being its own native installer to the PSGallery, the PSGallery needs to be “Trusted” before anything from it can be installed. To trust the PSGallery, entering the following command in the PowerShell session.
Note: This is optional and if it is skipped, you will be prompted to trust the gallery when entering the PowerCLI module install command
Set-PSRepository -Name "PSGallery" -InstallationPolicy "Trusted"
Find-Module "VMware.PowerCLI" | Install-Module -Scope "CurrentUser" -AllowClobber
Note: Alternatively, you could set the “-Scope” parameter to “AllUsers” and if you wanted to install a different version you could use the “-RequiredVersion” parameter and specify the version number.
Get-Module "VMware.PowerCLI" -ListAvailable | FT -Autosize
Get-Module "VMware.*" -ListAvailable | FT -Autosize
With VMware.PowerCLI now installed, you can connect to your vCenter Server or ESXi host and begin using its cmdlets to obtain information or automate tasks!
I went ahead and ran the following to ensure the module was imported.
Let’s test connecting to vCenter server…
Connect-VIServer -Server "<Server_Name>"
I also noticed an error when running the above command stating that the “InvalidCertificateAction” setting was “Unset” and not supported.
Set-PowerCLIConfiguration -InvalidCertificateAction "Ignore"
Now, if we try to connect to vCenter again, we should be successful.