-
-
Save MacsInSpace/79783cefb15e8479c1d6b8933fdb04bb to your computer and use it in GitHub Desktop.
powershell set default proxy for `Invoke-WebRequest`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# set to system default proxy | |
[System.Net.WebRequest]::DefaultWebProxy = [System.Net.WebRequest]::GetSystemWebProxy() | |
[System.Net.WebRequest]::DefaultWebProxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials | |
# or a custom one | |
[System.Net.WebRequest]::DefaultWebProxy = New-Object System.Net.WebProxy("http://localhost:8080") | |
# or use username and password auth | |
[System.Net.WebRequest]::DefaultWebProxy = New-Object System.Net.WebProxy("http://localhost:8080",$true) | |
[System.Net.WebRequest]::DefaultWebProxy.Credentials = New-Object System.Net.NetworkCredential($user, $passwd) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment