Installing VMware PowerCLI Cmdlets from the PowerShell Gallery

A great writeup for this process with detailed information is located here:
https://blogs.vmware.com/PowerCLI/2017/04/powercli-install-process-powershell-gallery.html

In a nutshell:

Find-Module -Name VMware.PowerCLI

You might be prompted for a new version of “NuGet”, which is fine- go ahead and say “yes” to the prompt to install. Then proceed with the below.

Install-Module -Name VMware.PowerCLI -Scope CurrentUser

Once that completed, the VMware PowerCLI Cmdlets were installed.

However, when running

Connect-VIServer

I got the following error:
Import-Module : File \\vmware-host\Shared
Folders\Documents\WindowsPowerShell\Modules\VMware.VimAutomation.Sdk\1.0.0.5334677\VMware.VimAutomation.Sdk.ps1 cannot
be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at
http://go.microsoft.com/fwlink/?LinkID=135170.

So I went ahead and did the following:
– Launch the Windows PowerShell app using the “Run As Administrator” option.
Then type in:

Set-ExecutionPolicy RemoteSigned

Once that was done, then

Connect-VIServer

worked.

Leave a Reply