Forked from famousgarkin/powershell-proxy-set-clear.ps1
Created
September 12, 2018 13:49
-
-
Save sparkydogX/5aae3fc4b11e2d67995b0c64910002e8 to your computer and use it in GitHub Desktop.
PowerShell Set-Proxy, Clear-proxy
This file contains 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
# NOTE: registry keys for IE 8, may vary for other versions | |
$regPath = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' | |
function Clear-Proxy | |
{ | |
Set-ItemProperty -Path $regPath -Name ProxyEnable -Value 0 | |
Set-ItemProperty -Path $regPath -Name ProxyServer -Value '' | |
Set-ItemProperty -Path $regPath -Name ProxyOverride -Value '' | |
[Environment]::SetEnvironmentVariable('http_proxy', $null, 'User') | |
[Environment]::SetEnvironmentVariable('https_proxy', $null, 'User') | |
} | |
function Set-Proxy | |
{ | |
$proxy = 'http://example.com' | |
Set-ItemProperty -Path $regPath -Name ProxyEnable -Value 1 | |
Set-ItemProperty -Path $regPath -Name ProxyServer -Value $proxy | |
Set-ItemProperty -Path $regPath -Name ProxyOverride -Value '<local>' | |
[Environment]::SetEnvironmentVariable('http_proxy', $proxy, 'User') | |
[Environment]::SetEnvironmentVariable('https_proxy', $proxy, 'User') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
用来设置powershell中的代理