PowerShell has quickly become the defacto standard for automating Windows environments over the past several years. However, using PowerShell, admins can automate other environments, including VMware vSphere using PowerShell. PowerShell is a modular platform that extends PowerShell with both “snap-ins” and modules to add vendor-specific cmdlets into your PowerShell environment. In this quick how-to post, we will look at installing VMware PowerShell management with VMware PowerShell module download to manage and automate your VMware vSphere environment.
VMware PowerCLI – the VMware PowerShell Module
In case you are new to automating VMware vSphere environments with PowerShell, VMware’s PowerShell management module is called PowerCLI. The newest versions of PowerCLI are module-based which makes the management of PowerCLI much easier than the legacy “snap-in” that you used to have to download the MSI, install, and perform your own lifecycle management within the Windows programs and features environment.
VMware PowerCLI allows you to interact with vCenter Server to manage, configure, and automate your vSphere environment.
To install the VMware PowerShell module download, you can do this natively from within your PowerShell console. You can see the latest version of the VMware PowerShell module by issuing the command:
- find-module VMware.PowerCLI
This will display the latest version of PowerCLI that is available from the PowerShell Gallery. To install the module, you issue the cmdlet below:
- Install-Module VMware.PowerCLI
As you can see, it will perform a VMware PowerShell module download and install the module in your PowerShell installation. Make sure you have administrative privileges and Internet access before you download and install VMware PowerCLI.
Next, you can import the module in PowerShell for use by issuing the command:
VMware PowerShell module – PowerCLI module cmdlets
Once you have installed the VMware PowerShell module, you can start using the module cmdlets available for use with PowerCLI. One of the first module cmdlets you will see is the ability to opt-in or out of the CEIP program with the VMware.PowerCLI module.
- Set-PowerCLIConfiguration -scope user -ParticipateInCEIP $false
How do you connect to vCenter Server? This is another simple cmdlet once you have installed VMware.PowerCLI.
- Connect-VIServer <your vCenter Server>
If you receive SSL errors when connecting to your vCenter Server, you can turn off SSL certificate checking with the following cmdlet:
- Set-PowerCLIConfiguration -InvalidCertificateAction Ignore
Updating VMware PowerShell Module Download
Once you have downloaded and installed the VMware PowerShell module in your PowerShell environment, performing lifecycle management is easily accomplished using the normal PowerShell update-module cmdlet. This makes updating to the latest and greatest VMware PowerCLI module version extremely easy.
As you can see below, you can see what version of the VMware.PowerCLI module you are running with the:
- Get-Module VMware.PowerCLI
Then, you can update to the latest version of the VMware PowerShell module using the cmdlet:
- Update-Module VMware.PowerCLI
You will be asked if you trust downloading from the PowerShell Gallery.
PowerShell vs PowerShell Core
You may have questions regarding the VMware PowerShell module download based on the version of PowerShell you are using. When you download VMware PowerCLI in one version of PowerShell, such as Windows PowerShell, does this mean you will have the module installed automatically if you download PowerShell Core? No.
You will need to redownload VMware PowerCLI for each version of PowerShell you have installed. Which version is better? Both work equally well I would say with VMware PowerCLI. However, you will want to note that PowerShell Core is the newer of the two versions of PowerShell and will be the one moving forward that Microsoft will develop and recommend as the platform for most. It is also a cross-platform environment whereas Windows PowerShell is for Windows only. With PowerShell Core, you can run it on Windows, Linux, and Mac.
I also have noted many of the scripts I like to use from the community such as those from William Lam’s “Nested ESXi” scripts now require PowerShell Core as the cmdlets used in the script are from PowerShell Core. If you want to know which version of PowerShell Core to install, read my blog post here:
As a note, the process for installing and managing the lifecycle of your VMware.PowerCLI module in PowerShell Core is the same as Windows PowerShell. The cmdlets listed here all work with PowerShell Core as well.
The VMware PowerShell Module Download involves simply opening your PowerShell environment, whether Windows PowerShell or PowerShell Core and installing the VMware PowerCLI module from the PowerShell Gallery. Lifecycle management with the VMware PowerShell module is easy with the update-module cmdlet.
You can use the VMware PowerShell module in either Windows PowerShell or PowerShell Core. PowerShell Core has advantages to note such as the newest platform moving forward, cross-platform architecture, and the latest features and functionality. Many scripts are being written to take advantage of PowerShell Core now instead of Windows PowerShell.