PowerShell behind a proxy

Since most of my work is done behind corporate firewalls, it’s unfortunate that PowerShell does not use the default proxy settings to connect to internet sources like online help or the PowerShell Gallery, but instead gives great errors like:

2016-10-03-13_15_15-administrator_-windows-powershell
WARNING: Unable to download the list of available providers. Check your internet connection.

A real helpfull message… I can reach the site in my browser, so it’s just PowerShell who can’t reach the site using the proxy.

After some online searching I ifound the following WebRequest Class on MSDN, which has a DefaultWebProxy property. Let’s try to use it.

If you need to authenticate to the proxy, set UseDefaultCredentials to $True. And voila, I can reach the repository again!

Add the config to your $PROFILE, in order to use it in every PowerShell session and your good to go!

Leave a Reply