The myriad of ways of setting the Windows proxy


Powershell

[Environment]::SetEnvironmentVariable("HTTPS_PROXY", "http://someproxy:3128", "Machine")

Query permanent variable.

[environment]::GetEnvironmentVariable("HTTPS_PROXY", "Machine")

Clear permanent variable

[Environment]::SetEnvironmentVariable("HTTP_PROXY", $null, "Machine")
[Environment]::SetEnvironmentVariable("HTTPS_PROXY", $null, "Machine")

Display proxy env variables

Get-ChildItem Env:

Short hand version of above

gci env:

Yet another way to do the same thing

dir env:

Return all env variables with the “path”

Get-ChildItem Env:*path* | format-list
netsh winhttp show proxy
netsh winhttp set proxy http://someproxy:3128

Resetting winhttp proxy

netsh winhttp reset proxy

Use proxy currently being used by ie

netsh winhttp import proxy source=ie

*winhttp can also retrieve settings from ie.

This should work for cmd sessions.

set http_proxy=http://someproxy:8080/
set https_proxy=https://someproxy:8080/

This should work for Powershell sessions

$env:http_proxy = "http://169.254.123.45:3128"
$env:https_proxy = "http://169.254.123.45:3128"

comments powered by Disqus