How to Install PowerCLI in Windows via PowerShellGet [Video]

So, I was doing some maintenance on my vSphere environment the other day and needed to get PowerCLI out for something. The only problem was, I had recently built a new workstation that had become my new daily driver, and I hadn’t yet needed to install PowerCLI on it. I started tinkering around with Google attempting to track down the download and even stumbled through the downloads manually at my.vmware.com. For the life of me, I couldn’t find a setup file for PowerCLI that was somewhat current to save my life! Finally, I stumbled upon of the official documentation that showed PowerCLI being installable from the CLI, no setup file needed! I figured that if I had a hard time tracking down this information it may be useful for others if I put a quick blog post together discussing the specifics.

PowerShellGet to the Rescue!

This new installation feature is really made possible via Microsoft’s PowerShellGet functionality. PowerShellGet is something that I can best describe as a package management toolkit. If you’re familiar with the Linux and open source world then you’ll feel right at home with it. It feels like something very akin to Apt-Get. Simple package management on a Windows platform via the command line!

One thing to note when using PowerShellGet for the first time. You may run into some notification messages like the below. In typical package manager fashion PowerShellGet will pull in anything needed to do its job. Additionally, it will let you know when you’re using an untrusted repository. You can simply say yes to both of the below messages in this case as you’ll need NuGet and the PSGallery is a reputable source for software, but be sure to do your homework if you’re adding a repo from somewhere else!

PowerCLI Installation on Windows

Installation of PowerCLI, in this case, is a simple one-liner with a few caveats. If you’ve never installed PowerCLI before and don’t have the Hyper-V Management Modules installation you can simply run

Install-Module -Name VMware.PowerCLI

The process will run (As shown in the video below) and may prompt you with the above prompts if you’ve never used PowerShellGet before. Once this process is complete you can run the below to verify that the module was successfully installed and also see versioning information.

Get-Module VMware.PowerCLI -ListAvailable

There are a few things to be aware of:

  1. If you have a previous version of PowerCLI installed, you can force a side-by-side installation by passing the -force parameter to the installation cmdlet. In this case, to utilize a particular version of PowerCLI, you can switch between versions using the Import-Module cmdlet to select the applicable module. Otherwise, Powershell should pick and use the latest and greatest
  2. If you have the Hyper-V PowerShell cmdlets installed, the installation will throw an error, warning that some of those module names already exist. You can pass the -AllowClobber parameter to force it to continue. You’ll still be able to use the relevant Hyper-V cmdlets in the future, you’ll just have to pass the “Import-Module -Name Hyper-V” in order to do so.

The other thing to note is that if you’ve been using PowerCLI for some time, you’ll know that when connecting to endpoints with invalid certificates it will simply throw a warning, but allow you to connect anyway. Newer versions of PowerCLI will not allow that. The command will fail as shown below

You’ll need to run the below to Set the “InvalidCertificateAction” setting

Set-PowerCLIConfiguration -InvalidCertificateAction Ignore

Of course, this setting and certificate policies, in general, will depend on your organization’s security policies so be sure to check on that before using this in highly secured environments.

See the Process in Action!



Wrap-Up

That’s it! That’s all that is required in order to get the newer versions of PowerCLI working on Windows! We’ll be sure to discuss the ins and outs of this process from the Linux command line in a future post as that is a bit more of a complex process. Stay tuned for that one!

Also if you have any questions or any PowerCLI stories you’d like to share, be sure to let us know in the comments section below!

Thanks for reading!

[the_ad id=”4738″][thrive_leads id=’18673′]

Altaro VM Backup
Share this post

Not a DOJO Member yet?

Join thousands of other IT pros and receive a weekly roundup email with the latest content & updates!

Leave a comment

Your email address will not be published.

Microsoft 365 Security checklist - free eBook