Home > Blogs > VMware PowerCLI Blog


Updating PowerCLI through the PowerShell Gallery

PowerCLI 6.5.2 has been released! This is the second release of PowerCLI to the PowerShell Gallery, so it’s time to figure out how to update your PowerCLI versions to the latest and greatest.

We’ll cover a couple scenarios:

  • Updating from PowerCLI 6.5.1, installed online from the PowerShell Gallery
  • Updating from PowerCLI 6.5.1, installed offline from the PowerShell Gallery
  • Updating from PowerCLI 6.5 R1 or prior

Updating from PowerCLI 6.5.1, Online

This will be the easiest update process PowerCLI has ever offered! Open a PowerShell session, type the following command:
Update-Module -Name VMware.PowerCLI

Update Module Example

That’s it, you’re now running the latest and greatest PowerCLI release!

However, if you happen to have run into the following error it’s possible that PowerCLI was installed by the offline method:
Update-Module : Module ‘VMware.PowerCLI’ was not installed by using Install-Module, so it cannot be updated.

There’s two main ways to resolve this:
Option 1. Remove the PowerCLI modules from where they currently reside
1a. Run the following command:
Get-Module VMware.* -ListAvailable
1b. There should be a ‘Directory’ label at the top of the response. Browse to that directory and remove all the directories starting with ‘VMware.*’

Example Usage of Get-Module

1c. Perform the following command:
Install-Module -Name VMware.PowerCLI -Scope CurrentUser

Option 2. Use the force… And by that, I mean perform the Install-Module command with the ‘Force’ parameter
2a. Perform the following command:
Install-Module -Name VMware.PowerCLI -Scope CurrentUser -Force

Updating from PowerCLI 6.5.1, Offline

This process will work exactly the same as the installation process.

1. From a computer that has internet access, run the following command:
Save-Module -Name VMware.PowerCLI -Path C:\Path\To\Desired\Folder
2. Take the downloaded modules and make them available to the offline system
3. Copy and replace the individual PowerCLI module folders to the location where the prior modules were placed.

Copying over the PowerCLI modules after saving them locally

Updating from PowerCLI 6.5 R1 or prior releases

If you happen to be running an older version of PowerCLI which involved an MSI installer, we can verify that by running the following command:
Get-Module VMware* -ListAvailable

Example on showing a list of available PowerCLI modules

If the majority of PowerCLI modules are versions listed at 6.5.0 or older, as shown above, proceed through the following steps.

PowerCLI 6.5 R1 (or older) Uninstallation Steps:
1. Uninstall PowerCLI through the Control Panel
2. Browse to the following directory: C:\Program Files (x86)\VMware\Infrastructure\
3. If there is a ‘vSphere PowerCLI’ directory, delete it

Uninstalling Prior PowerCLI Versions

PowerCLI 6.5.2 Online Installation
This works exactly the same as how the installation did for PowerCLI 6.5.1.

Within a PowerShell session, type the following command: $PSVersionTable

PSVersion Table Sample Output

If the PSVersion is a Value of 5.0 or above:
1. Run the following command:
Install-Module -Name VMware.PowerCLI –Scope CurrentUser
2. If asked to update ‘NuGet Provider’, choose ‘Y’ to install and import the newer version.
3. If asked to ‘install modules from an untrusted repository’, choose ‘Y’ to accept.

Install Module usage to PowerCLI 6.5.2

If the PSVersion is a Value of 4.x or 3.x:
1. Install a current version of PowerShellGet through one of the following two options:
1a. Install Windows Management Framework 5.1
1b. Install PackageManagement PowerShell Modules
2. Run the following command:
Install-Module -Name VMware.PowerCLI –Scope CurrentUser
3. If asked to update ‘NuGet Provider’, choose ‘Y’ to install and import the newer version.
4. If asked to ‘install modules from an untrusted repository’, choose ‘Y’ to accept.

PowerCLI 6.5.2 Offline Installation
1. From a computer that has internet access, run the following command:
Save-Module -Name VMware.PowerCLI -Path C:\Path\To\Desired\Folder
2. Take the downloaded modules and make them available to the offline system
3. Copy and replace the individual PowerCLI module folders to one of the following locations:
3a. Local User Usage: $home\Documents\WindowsPowerShell\Modules
3b. All User Usage: $pshome\Modules

Example file structure for an offline PowerCLI Installation

The PowerCLI Installation Walkthrough Video also works in this scenario too. However, following the instructions in the video will now result in PowerCLI 6.5.2 being installed:

This entry was posted in General and tagged , , on by .
Kyle Ruddy

About Kyle Ruddy

Kyle Ruddy is a Senior Technical Marketing Engineer at VMware in the Cloud Platform Business Unit. Kyle currently focuses on vSphere with Operations Management as well as all things API, SDK, and CLI. Kyle can be found blogging on VMware blogs, http://blogs.vmware.com/vSphere and http://blogs.vmware.com/PowerCLI, and his personal blog, http://www.thatcouldbeaproblem.com. You can follow Kyle on twitter as @kmruddy.

14 thoughts on “Updating PowerCLI through the PowerShell Gallery

  1. Pingback: New Release: VMware PowerCLI 6.5.2 - VMware PowerCLI Blog - VMware Blogs

  2. Pingback: New Release: VMware PowerCLI 6.5.2 – VMpro.at

  3. Miguel Angel Moreno

    How I can know if I running the lastest version? The “Get-PowerCLIVersion” command shows me this:

    PowerCLI Version
    —————-
    VMware PowerCLI Core 1.0 build 5327113
    —————
    Component Versions
    —————
    VMware vSphere PowerCLI Component 1.22 build 5327113
    VMware VDS PowerCLI Component 5.1 build 5327113
    VMware VDS PowerCLI Component 1.21 build 5327113

    Reply
    1. Kyle RuddyKyle Ruddy Post author

      Yes, it should be possible with 6.5.2 and it should have been possible in 6.5.1.

      In some environments there has been a couple ‘gotchas’, so if you run into issues… let us know!

      Reply
  4. LucD

    Don’t forget the -AllowClobber switch on the Install-Module cmdlet when you have duplicate cmdletnames.
    For example, when you have the RSAT modules installed, there is already a Get-Cluster cmdlet present.

    Reply
    1. MacKopes

      For those of you wanting to script the upgrade from ‘pre-powercli 6.5.1’ and uninstall the old one, I found this helpful. It cleans up the old PowerCLI plus VIX and the VMRC 5.1 that are installed with older PowerCLI versions.

      Write-Host “[Collect Installed Program Information]”
      $installed = Get-WmiObject -Class Win32_Product
      $PowerCLI = $installed | ? Name -eq ‘VMware vSphere PowerCLI’ | Select-Object -ExpandProperty IdentifyingNumber -First 1
      $VMRC = $installed | ? Name -eq ‘VMware Remote Console Plug-in 5.1’ | Select-Object -ExpandProperty IdentifyingNumber -First 1
      $VIX = $installed | ? Name -eq ‘VMware VIX’ | Select-Object -ExpandProperty IdentifyingNumber -First 1

      if ($PowerCLI) {
      Write-Host “[Uninstall PowerCLI]”
      Start-Process -FilePath MsiExec.exe -ArgumentList “/uninstall $PowerCLI /qb!” -Wait
      }

      if ($VMRC) {

      Write-Verbose “[Uninstall VMware Remote Console]”
      Start-Process -FilePath MsiExec.exe -ArgumentList “/uninstall $VMRC /qb!” -Wait
      }

      if ($VIX) {
      Write-Verbose “[Uninstall VMware VIX]”
      Start-Process -FilePath MsiExec.exe -ArgumentList “/uninstall $VIX /qb!” -Wait
      }

      Reply
  5. Nasko

    Hello,

    Is there an option to bundle all modules in a single zip file?
    You’ve made our lives so difficult ….

    Thanks!

    Reply
    1. Kyle RuddyKyle Ruddy Post author

      Jeff: PowerCLI 6.5.2 (or, technically now 6.5.4) can be installed directly using Install-Module -Name VMware.PowerCLI That command will always install the latest and greatest version available!

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

*