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
To add the PowerShell Core repository to Ubuntu, run the following command. Enter your password if prompted
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
To register the repository, enter the following command. Again, enter your password if prompted.
curl https://packages.microsoft.com/config/ubuntu/17.04/prod.list | sudo tee /etc/apt/sources.list.d/microsoft.list
Great! With the prerequisites complete, it’s time to install PowerShell Core 6.0.1. Run the following command to do so and enter your password when prompted.
sudo apt-get install -y powershell
Awesome! Now, to launch a PowerShell session in CentOS, enter the following.
pwsh
Within a PowerShell session, you can check the version of PowerShell by running the following.
$PSVersionTable.PSVersion
As new versions of PowerShell are released, simply update by running the following command.
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"
Next, run the following command to install the VMware.PowerCLI module. This will find and install the latest version of the module available in the PSGallery
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.
Once this finishes, we can check to make sure the module is installed by running the following command.
Get-Module "VMware.PowerCLI" -ListAvailable | FT -Autosize
And if you’d like to see all of the VMware installed modules, run the following.
Get-Module "VMware.*" -ListAvailable | FT -Autosize
As new versions of VMware.PowerCLI are released, you can run the following command to update it.
Update-Module "VMware.PowerCLI"
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.
Import-Module "VMware.PowerCLI"
I noticed one caveat, the SRM module does not seem to be supported in PowerShell Core, so I hope that gets resolved soon.
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.
To bypass this, enter the following command and then enter “Y” when prompted. This will set the parameter for the current user.
Set-PowerCLIConfiguration -InvalidCertificateAction "Ignore"
Note: Alternatively, you can also use the “-Scope” parameter and enter “Session”, “User”, or “AllUsers” to apply the setting to those options respectively.
Now, if we try to connect to vCenter again, we should be successful.
Well, that about does it! I hope that you have found this post useful and I thank you for stopping by and reading my content. Until next time!
-virtualex-
Pingbacks:
Install PowerShell and VMware PowerCLI on Ubuntu by virtualex is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.