As you’ve surely seen, I love me some PowerCLI. So I was really happy when I saw that PowerCLI is now available on the PowerShell Gallery! What this means is that it is no longer a package you install on a server, it’s a set of modules you load from the gallery. When there’s a new version available, you just go get it. Because it’s now a bunch of files, not only do you not need to go to vmware.com to find the download link, you can also install it without requiring administrative access! That’s pretty awesome when you’re a tenant on a system, and it’s pretty awesome for the owners of the system, too (no needing to punt all your PowerCLI users so the files aren’t locked during an upgrade). I fill both roles from time to time, so I’m really happy about this improvement! Read more about the change in this VMware PowerCLI Blog article by Kyle Ruddy.
The article will guide you through the setup just fine, so I won’t dwell on that part very much, but if you’ve followed my PowerShell Profile article, there’s one small change to make: uninstall the old version of PowerCLI, then edit your posh profiles with
notepad $profile and remove whatever version of the profile you used. Leave anything else you have added and close it out. Remember to do this once in PowerShell and once in PowerShell ISE if you use both.
Now, install the modules as the blog article recommends.
Find-Module -Name VMware.PowerCLI Install-Module -Name VMware.PowerCLI -Scope CurrentUser -AllowClobber
That’s it, you’re done! The modules will automatically be loaded as needed. You should be able to start typing
Connect-VIServer and see autocomplete working by tabbing it out in regular PowerShell, in the typeahead dialog in ISE, or however your PowerShell UI displays it. If you hit enter, the containing sub-modules are loaded immediately on-demand. You can import the entire suite of modules with
Import-Module VMware.PowerCLI,in your profile if you’d like, but it adds about 10 seconds to PowerShell startup on my laptop for minimal gain vs on-demand loading. However, it does give you the look of the old PowerCLI desktop shortcut, if you so desire it.
When upgrading to PowerCLI v10+, you may need to add
-SkipPublisherCheck due to differences in the issuer information that PowerShell caches.
If, for some reason, the module is not found by PowerShell after installation, check out the value of
$env:PSModulePath. It should include
C:\Users\rnelson0\Documents\WindowsPowerShell\Modules, which is where
Install-Module installs the files to. If it does not, you’ll need to modify it. Mine was funky because I apparently edited the environment variable portion of my windows install, even though I don’t remember it.
To keep up with PowerCLI from the Gallery, just run
Update-Module -Name VMware.PowerCLI once in a while. Easy peasy. Enjoy!