Are you trying to install PowerCLI from your corporate server? If yes, then you might have faced some sort of errors simillar to this-
Based on my experience this issue happens mainly because your powershell session is not able to talk to powershell gallery through Nuget package providers. This happens because of corporate proxy connection.
Sometime you don’t have required package provider. In that case ensure FIPS compliant encryption is disabled.
For detailed steps please refer below
- Ensure you are running with PSVerion 5 or above. run $psversiontable to check the ps version.
- Ensure you have required package providers
- Open powershell as an administrator and Run this Get-PackageProvider
- If you see output as below then you are good. check the step 2.
- If you do not see any package provider than there could be a possibility that FIPS is enabled on your system.
- Disable FIPS
- open gpedit.msc
- Computer Configuration > Windows Settings > Security Settings > Local Policies > Security Options
- In the Details pane, double-click System cryptography: Use FIPS-compliant algorithms for encryption, hashing, and signing and Disable it.
- Disable FIPS
Important: if you do not have default package provider as shown above (more specifically PowerShellGet) then you will not be able to use commands such as install-module/ Find-Module /Update-Module /Save-module etc.
2. Check the PSRepository
- Ensure that Powershell gallery is register as PSRepository.
- Run This command
- If you see above warning then it means that there is no PSRepo exists.
- Register PSRepository.
- Run this to register a PSRepository.
1Register-PSRepository -Name PSGallery -SourceLocation https://www.powershellgallery.com/api/v2/ -PublishLocation https://www.powershellgallery.com/api/v2/package/ -ScriptSourceLocation https://www.powershellgallery.com/api/v2/items/psscript/ -ScriptPublishLocation https://www.powershellgallery.com/api/v2/package/ -InstallationPolicy Trusted -PackageManagementProvider NuGet
- if you recieve below error, then your corporate proxy server is not allowing PSRepository to communiate with your system.
- bypass connections via a proxy server.
- You would require proxy server details (ProxyServerName and Port number)
- Create a powershell profile by following steps, If its not there. check the below snap and follow exactly the samae
- New-item -itemtype file -Path $Profile
- Test-Path $profile
- notepad $profile
- With this pase below lines of code in your profile, save and close it. Change your proxy server address and port number
- This will allow communication to PSgallery after you restart your PSSession.
[system.net.webrequest]::defaultwebproxy = new-object system.net.webproxy('http://[YourProxyDNS]:[yourProxyPort]')
[system.net.webrequest]::defaultwebproxy.credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
[system.net.webrequest]::defaultwebproxy.BypassProxyOnLocal = $true
- Again run get-Psrepository and you have PSGallery available and registered as ps repository
3. Now you have Packagemanager and PSRepository.
4. Run Install-module -name VMware.PowerCLI -Force
5. This will require Nuget and as you have allowed PSgallery communication via proxy, It will first install Nuget and then it will install VMware.Powercli.
Coporate systems do have proxy and sometime FIPS compliance enabled. These 2 security standards stops commincation to PSgallery. Disable FIPS if its enabled and not required and then allow communication to PSgallery via proxy server as explained above.