PowerCLI v10.0.0 Released
Introduction
Earlier this month VMware released PowerCLI v10.0.0. The previous version was v6.5.4 so you may be wondering why the big jump in version numbers. This apparently was due to a number of reasons but I personally like it was because PowerCLI is 10 years old so seemed appropriate to be v10.0.0. In this post I will details how to update to it and integrations
The main selling point on this version is that it’s cross platform. You can now run PowerCLI natively on Windows, Mac and Linux. The prerequisite for Mac and Linux is that PowerShell Core must be installed. PowerCLI v10.0.0 works with any version of PowerShell from v3 and up.
New Installation on PowerShell Core v6
Installation is very easy. In this example we are installing on a clean install of PowerShell Core v6.0.1:
PS C:\Program Files\PowerShell\6.0.1> Install-Module -Name VMware.PowerCLI -Scope AllUsers
You can confirm with:
PS C:\Program Files\PowerShell\6.0.1> Get-InstalledModule -Name VMware.PowerCLI -AllVersions
Version Name Repository Description
------- ---- ---------- -----------
10.0.0.7895300 VMware.PowerCLI PSGallery This Windows PowerShell module contains VMware.PowerCLI
Upgrade to PowerCLI 10.0.0 on Existing PowerShell 5.1 and PowerCLI 6.5.x
So on the computer I did this on I opened up the ‘legacy’ PowerShell 5.1 and ran the same command to check it was installed:
PS C:\Windows\system32> Get-InstalledModule -Name VMware.PowerCLI -AllVersions | Format-Table -AutoSize
Version Name Repository Description
------- ---- ---------- -----------
6.5.3.6870460 VMware.PowerCLI PSGallery This Windows PowerShell module contains VMware.PowerCLI
6.5.4.7155375 VMware.PowerCLI PSGallery This Windows PowerShell module contains VMware.PowerCLI
You can see I have PowerCLI versions 6.5.3 and 6.5.4 but no 10.0.0. As you can run PowerShell and PowerShell Core side by side you need to install PowerCLI in both versions.
To update PowerCLI:
PS C:\Windows\system32> Update-Module -Name VMware.PowerCLI -Force
PS C:\Windows\system32> Get-InstalledModule -Name VMware.PowerCLI -AllVersions | Format-Table -AutoSize
Version Name Repository Description
------- ---- ---------- -----------
10.0.0.7895300 VMware.PowerCLI PSGallery This Windows PowerShell module contains VMware.PowerCLI
6.5.3.6870460 VMware.PowerCLI PSGallery This Windows PowerShell module contains VMware.PowerCLI
6.5.4.7155375 VMware.PowerCLI PSGallery This Windows PowerShell module contains VMware.PowerCLI
Next I wanted to clean up the old versions of PowerCLI from PowerShell 5.1 and confirm they are gone. You could uninstall each older version and confirm by running the commands:
PS C:\Windows\system32> Uninstall-Module -Name VMware.PowerCLI -RequiredVersion 6.5.3.6870460
PS C:\Windows\system32> Uninstall-Module -Name VMware.PowerCLI -RequiredVersion 6.5.4.7155375
PS C:\Windows\system32> Get-InstalledModule -Name VMware.PowerCLI -AllVersions | Format-Table -AutoSize
Version Name Repository Description
------- ---- ---------- -----------
10.0.0.7895300 VMware.PowerCLI PSGallery This Windows PowerShell module contains VMware.PowerCLI
But an easier way to cycle through them all and just leave the latest version is:
Get-InstalledModule -Name VMware.PowerCLI | ForEach-Object {
$CurrentVersion = $PSItem.Version
Get-InstalledModule -Name $PSItem.Name -AllVersions | Where-Object -Property Version -LT $CurrentVersion
} | Uninstall-Module -Verbose
Credit to Andrew Palmer who posted the code in the comments of the VMware Blog annoucement.
Upgrade Issues
On another computer when I ran the Update-Module
command I was getting this error:
PS C:\WINDOWS\system32> Update-Module -Name VMware.PowerCLI
PackageManagement\Install-Package : Cannot convert value "10.0.0-beta7721354" to type "System.Version".
Error: "Input string was not in a correct format."
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1772 char:21
+ ... $null = PackageManagement\Install-Package @PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (Microsoft.Power....InstallPackage:InstallPackage) [Install-P
ackage], Exception
+ FullyQualifiedErrorId : InvalidCastParseTargetInvocation,New-PSGetItemInfo,Microsoft.PowerShell.Packag
eManagement.Cmdlets.InstallPackage
I found this post on the VMware {code} Forums that fixed the issue. Basically the version of PowerShellGet installed needs updated. To fix it first upgrade NuGet:
Install-PackageProvider -Name Nuget –Force
Restart the PowerShell session then run:
Install-Module –Name PowerShellGet –Force
You can then run the Update-Module
command successfully.
Conclusion
This is a milestone release of PowerCLI for VMware. Being cross platform will be a big boon to a lot of people. Also, as Microsoft leave behind the old PowerShell and only develop PowerShell Core kudos to VMware getting a version of PowerCLI that works with Core.