Now that PowerCLI is part of the PowerShell Gallery, you can install it using the native module installer…but there’s a catch. Windows Server 2012 R2 requires a couple of minor updates to get this process underway. You’ll know really quickly if you open up your PowerShell terminal or PowerShell ISE (as Administrator) and try the following command:
Find-Module -name VMware.PowerCLI
The issue is easily solved be deploying a more recent installer for the PackageManagement PowerShell Modules. Download the installer using this link and run the install:
Select the Download within the page once you’re there:
Choose the x64 version (assuming you’re running a 64-bit OS):
Run through the installation and accept the defaults. Nothing significant to worry about with this file as it’s a necessary update for what we need to do.
If you run the
Find-Module command again, you’ll see a much better result. You’ll be prompted to update your NuGet components which are used to pull resources from the PowerShell Gallery. Accept the update and then we can keep going:
Time to get back to the issues. Just relaunch your PowerShell terminal or ISE as an Administrator. We are running as Administrator so that we install the module for all users of the server. If you only want to run for your user then run your PowerShell session as your regular user and add
-scope CurrentUser to the Install-Module command. Run the following to install for all users:
Install-Module -name VMware.PowerCLI
Now we have to import the module into our session using the
Import-Module -name VMware.PowerCLI command:
Just like that, you’re up to date and running the latest and greatest PowerCLI goodness. Happy scripting!