PowerShell is unable to resolve the package source.
When trying to import an excel module in PowerShell an enterprise PC I encounter the next error:
unable to resolve package source ‘https //www.powershellgallery.com/api/v2/’
The reason is very simple – trying to install a PowerShell module behind a proxy?
Turns out it isn’t allowed through a proxy server, run this in a PowerShell session and try again:
$webclient=New-Object System.Net.WebClient
$webclient.Proxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredent
You also need to run:
[Net.ServicePointManager]::SecurityProtocol = “tls12”
after these lines to make it work.
At least I needed to.
Awesome , I was struggling with this for 2 hours , I though antivirus was blocking this but after running these lines it finally worked !!! thank you
[Net.ServicePointManager]::SecurityProtocol = “tls12
what exactly these lines do??
Hi.
[Net.ServicePointManager]::SecurityProtocol = “tls12 – will force TLS 1.2 as default in Powershell