'PowerShell Core proxy issues
I just wanted to share this with you all. If I knew what to ask for, I would have created a ticket up front. But what I found online was partly misleading. It was a combination of searching and trying, until I finally found the solution.
This issues was related to running PowerShell Core on a corporate machine, initially setup for Proxy use.
Problem description
After fresh installation of PowerShell Core, Install-Module where unable to resolve package source and Invoke-WebRequest "any-external-url" reported "No such host". This is all under Windows 10.
Solution 1:[1]
Solution to my issue
I had to do all of this to bypass the proxy.
- First was to unset the Environment Variable for the proxy. (Maybe you also need to do this for HTTP_PROXY environment variable)
Set-Item -Path Env:HTTPS_PROXY -Value ""
- Reset proxy for HttpClient
[System.Net.Http.HttpClient]::DefaultProxy = New-Object System.Net.WebProxy($null)
- Reset proxy for HttpWebRequest
[System.Net.HttpWebRequest]::DefaultWebProxy = New-Object System.Net.WebProxy($null)
I ended up adding them to the PowerShell 7 profile.
Hope it save some time for at least one more soul. :)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Magnus Karlsson |
