Run PowerShell through a Proxy

Posted by robd on August 27, 2019
powershell, Proxy

At work I’m behind a proxy which caused me havock when trying to install modules into PowerShell.

That was until I found this amazing script to tell PowerShell to use a proxy.

First open your PowerShell profile by either doing this in PowerShell:

notepad $PROFILE

Or open “Microsoft.PowerShell_profile.ps1” and  “Microsoft.PowerShellISE_profile.ps1” in Explorer with notepad:

C:\Users\%Username%\My Documents\WindowsPowerShell

Once open, paste in the following, editing the proxy address and port.

[]::defaultwebproxy = new-object'http://ProxyName:ProxyPort')

[]::defaultwebproxy.credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials

[]::defaultwebproxy.BypassProxyOnLocal = $true

This will use your current credentials you’re logged in with to pass the commands to the proxy server.

Test with a



Tags: , ,

1 Comment to Run PowerShell through a Proxy

  • Thank you!! I’ve been having issues getting my gMSA account to connect through the system proxy. It’s taken me months but finally works now after finding this article!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.