The latest versions of PowerCLI work very well on systems that have PowerShell Core installed. This is great as it allows us to work with VMware PowerShell cmdlets from a Linux system rather than being restricted to using Windows, if that isn’t your preference. It also opens up some other options such as running PowerShell from within a docker container.
In this short article we will take a look at how to install VMware PowerCLI on a system running PowerShell Core.
First of all, from a console session, start Powerhell:
$ pwsh
Once we have the PS />
Powershell prompt, we can go ahead and install the PowerCLI module from the PowerShell Gallery.
PS /> install-module -Name VMware.PowerCLI
You will then receive the following message if PSGallery isn’t currently trusted.
Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from
'PSGallery'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"):
After choosing [Y] Yes
the module will proceed to install, which will take a minute or so. As a quick way to check the PowerCLI commands are now available for us we can run a get-command
and look for anything with ‘vm’ in its name:
PS /> gcm *vm*
CommandType Name Version Source
----------- ---- ------- ------
Alias Answer-VMQuestion 12.4.0.18… VMware.VimAutomation.Core
Alias Apply-VMHostProfile 12.4.0.18… VMware.VimAutomation.Core
Alias Connect-VmcServer 12.4.0.18… VMware.VimAutomation.Vmc
Alias Disconnect-VmcServer 12.4.0.18… VMware.VimAutomation.Vmc
Alias Export-VM 12.4.0.18… VMware.VimAutomation.Core
Alias Get-PIVM 12.0.0.15… VMware.VimAutomation.Cloud
Alias Get-PIVMTemplate 12.0.0.15… VMware.VimAutomation.Cloud
Alias New-PIVM 12.0.0.15… VMware.VimAutomation.Cloud
Alias Restart-PIVM 12.0.0.15… VMware.VimAutomation.Cloud
Alias Restart-PIVMGuest 12.0.0.15… VMware.VimAutomation.Cloud
Alias Shutdown-VMGuest 12.4.0.18… VMware.VimAutomation.Core
Alias Start-PIVM 12.0.0.15… VMware.VimAutomation.Cloud
Alias Stop-PIVM 12.0.0.15… VMware.VimAutomation.Cloud
Alias Stop-PIVMGuest 12.0.0.15… VMware.VimAutomation.Cloud
Alias Suspend-PIVM 12.0.0.15… VMware.VimAutomation.Cloud
Function Initialize-CertificateManagementVcenterVmcaRootCr… 1.0.104.1… VMware.Sdk.vSphere.vCenter.CertManagement
Function Initialize-NamespacesInstancesVMServiceSpec 1.0.104.1… VMware.Sdk.vSphere.vCenter.Namespaces
Function Initialize-VchaClusterNodeVmInfo 1.0.104.1… VMware.Sdk.vSphere.vCenter.VCHA
Function Initialize-VchaClusterVmInfo 1.0.104.1… VMware.Sdk.vSphere.vCenter.VCHA
Function Initialize-VMClonePlacementSpec 1.0.104.1… VMware.Sdk.vSphere.vCenter
Function Initialize-VMCloneSpec 1.0.104.1… VMware.Sdk.vSphere.vCenter
Function Initialize-VmConsoleTicketsCreateSpec 1.0.104.1… VMware.Sdk.vSphere.vCenter.Vm
Good news! We now have the VMware PowerCLI cmdlets installed. We can check all the modules that have been installed using get-module
:
PS /> get-module
Microsoft.PowerShell.Management PSReadLine VMware.VimAutomation.Cloud VMware.VimAutomation.License VMware.VimAutomation.Storage
Microsoft.PowerShell.Utility VMware.CloudServices VMware.VimAutomation.Common VMware.VimAutomation.Nsxt VMware.VimAutomation.Vds
PackageManagement VMware.Vim VMware.VimAutomation.Core VMware.VimAutomation.Sdk VMware.VimAutomation.Vmc
PowerShellGet VMware.VimAutomation.Cis.Core VMware.VimAutomation.HorizonView VMware.VimAutomation.Srm VMware.VimAutomation.vROps
As you can see, we have modules for interacting with many VMware products, including NSX-T and vROPs. We can check the version of individual modules. For example:
PS /> get-module vmware.vimautomation.vrops
ModuleType Version PreRelease Name ExportedCommands
---------- ------- ---------- ---- ----------------
Script 12.2.0.17… VMware.VimAutomation.vROps {Connect-OMServer, Disconnect-OMServer, Get-OMAlert, Get-OMAlertDefinition…}
We’re now ready to start working with PowerCLI in Powershell Core! In this article you have learned how to import the VMware PowerCLI modules into PowerShell core, along with how to confirm they have installed correctly, and which version of the module you have present.