VMware PowerCLI 6.5 Module Failed to Load

PowerCLI

Recently, I met an issue for the newly installed PowerCLI 6.5. When launching the PowerCLI, the PowerCLI module failed to load with below error.:

Unable to find type [VMware.VimAutomation.Sdk.Util10.ProductInfo].

At C:\Program Files (x86)\VMware\Infrastructure\PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1:71 char:28

It looks like the PowerCLI modules are failed to load. After the  investigation, I ran the check below:

  1. Launch the PowerShell and run command “$Env:PSModulePath”.
  2. Check the output that whether PowerCLI module path is in the output, by default the PowerCLI installation path is “C:\Program Files (x86)\VMware\Infrastructure\PowerCLI\Modules”

In my case, the PowerCLI module path is missed in PowerShell environment variable “$Env:PSModulePath”.

 

The fix is straight forward, reference below link to add the path into “$Env:PSModulePath”.

https://docs.microsoft.com/en-us/powershell/developer/module/modifying-the-psmodulepath-installation-path#to-add-locations-to-the-psmodulepath-variable

In general, there are two ways to fix:

 

  • The temporary workaround is:
  1. Launch the PowerCLI;
  2. Run below command in PowerCLI;
“$env:PSModulePath = $env:PSModulePath + "; C:\Program Files (x86)\VMware\Infrastructure\PowerCLI\Modules "
  1. Run below commands in PowerCLI to initialize the PowerCLI; and
cd ‘C:\Program Files (x86)\VMware\Infrastructure\PowerCLI\Scripts’
.\Initialize-PowerCLIEnvironment.ps1
  1. The PowerCLI module will be loaded.

 

  • The permanent fix is:
  1. Launch PowerShell as administrator;
  2. Run the below commands; and
$CurrentValue = [Environment]::GetEnvironmentVariable("PSModulePath", "Machine")
[Environment]::SetEnvironmentVariable("PSModulePath", $CurrentValue + ";C:\Program Files (x86)\VMware\Infrastructure\PowerCLI\Modules", "Machine")

This will modify the registry for the environment variable “$PSModulePath” and permanently add PowerCLI module path.

  1. Launch the PowerCLI, the PowerCLI module should be loaded.

 

In the end, it is highly recommended to read below post if not familiar with PowerCLI modules.

https://blogs.vmware.com/PowerCLI/2015/03/powercli-6-0-introducing-powercli-modules.html

Leave a Reply

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