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:
- Launch the PowerShell and run command “$Env:PSModulePath”.
- 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”.
In general, there are two ways to fix:
- The temporary workaround is:
- Launch the PowerCLI;
- Run below command in PowerCLI;
“$env:PSModulePath = $env:PSModulePath + "; C:\Program Files (x86)\VMware\Infrastructure\PowerCLI\Modules "
- Run below commands in PowerCLI to initialize the PowerCLI; and
cd ‘C:\Program Files (x86)\VMware\Infrastructure\PowerCLI\Scripts’ .\Initialize-PowerCLIEnvironment.ps1
- The PowerCLI module will be loaded.
- The permanent fix is:
- Launch PowerShell as administrator;
- 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.
- 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