darrylcauldwell.com On a journey around the datacenter and public cloud.

PowerCLI 6.0 R1 Module Path Issue

The install for PowerCLI 6.0 R1 sets the module path for the logged on user but no one else,
on a shared machine the other users get a module path error when PowerCLI launches and it tries to use a module to display version.

‘Get-PowerCLIVersion : The term ‘PowerCLIVersion’ is not recognised as the name of a cmdlet, function, script file, or operable program.’

The following code snippet from aaronk sets the correct values machine wide.

$PowerCLIModulePath = "C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Modules"
$OldModulePath = [Environment]::GetEnvironmentVariable('PSModulePath','Machine')
if ($OldModulePath -notmatch "PowerCLI") {
Write-Host "[Adding PowerCLI Module directory to Machine PSModulePath]" -ForegroundColor Green
$OldModulePath += ";$PowerCLIModulePath"
[Environment]::SetEnvironmentVariable('PSModulePath',"$OldModulePath",'Machine')
} else {
Write-Host "[PowerCLI Module directory already in PSModulePath. No action taken]" -ForegroundColor Cyan
}

Be social and share this post!