PowerCLI 6.5.1 Installation

1 minute read

PowerCLI 6.5.1 was released on Friday and the big change in this version is that it’s deployed using the PowerShell Gallery.

This is great - no more having to login the VMware portal, finding the installer, then installing. This is a great move that will really help people install PowerCLI onto their computers. The next great part of this version is the modules are loaded automatically when starting PowerShell! Simply start typing a PowerCLI cmdlet and PowerShell will load the PowerCLI module automatically.

Kyle Ruddy (@kmruddy) has a blog post detailing how to install it. You can find that here: Welcome PowerCLI to the PowerShell Gallery – Install Process Updates

Broadly speaking the install steps are:

Ensure Windows Management Framework 5 or greater is installed. You should always have the latest version installed which is at this time WMF 5.1. You can grab it here Uninstall existing versions of PowerCLI Install PowerCLI from the PowerShell Gallery.

These steps assume you already have the NuGet provider installed in PowerShell and the PowerShell Gallery is a trusted source.

There seems to be a few manual steps to perform, so lets script it. The script is kinda ugly but heck it works. I could spend more time to refine it honestly I don’t think it’s worth the effort - it works! The script does the following:

  1. Checks WMF v5 or greater is installed
  2. Installs NuGet if not already present
  3. Uninstalls any previously installed versions of PowerCLI
  4. Adds the PowerShell Gallery as a trusted source
  5. Installs the PowerCLI module for all users
  6. Confirms the modules have been installed

The prerequisite is you need WMF v5 or greater. The script will throw an error if you don’t have it installed. Secondly this installs PowerCLI for all users on the computer. If you just want it on your profile change -AllUsers on line 33 to -CurrentUser

#WMF Version 5 or later required
#requires -Version 5

#Install NuGet if not already installed
$testNuGet = $null
$nuGet = Get-PackageProvider | Select-Object -ExpandProperty Name
foreach($result in $nuGet){
    if($result -eq "NuGet"){
        $testNuGet = $true
if($testNuGet -eq $true){
    Write-Host "NuGet is already installed" -ForegroundColor Magenta
    Write-Host "NuGet is being installed" -ForegroundColor Magenta
    Install-PackageProvider -Name NuGet -Force

Write-Host "Remove previous versions of PowerCLI" -ForegroundColor Magenta
$app = Get-WmiObject -Class Win32_Product -Filter "Name like '%PowerCLI%'"
$app.Uninstall() | Out-Null

#Remove any lingering directories from the old PowerCLI version
If (Test-Path "C:\Program Files (x86)\VMware\Infrastructure\"){
 Remove-Item "C:\Program Files (x86)\VMware\Infrastructure\"

Write-Host "Adding the PowerShell Gallery as a Trusted Source" -ForegroundColor Magenta
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted

Write-Host "Installing the PowerCLI Module" -ForegroundColor Magenta
Install-Module -Name VMware.PowerCLI -Scope AllUsers -AllowClobber

Write-Host "Show installed PowerCLI Modules" -ForegroundColor Magenta
Get-Module -Name VMware* -ListAvailable | Format-Table -Property Version,Name