Created
April 18, 2020 04:19
-
-
Save qmdx00/04c88d5172b2b50252cd2bc7c0a8257f to your computer and use it in GitHub Desktop.
windows powershell proxy config
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
# file path: | |
# ~\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 | |
function Set-Proxy | |
{ | |
$proxy = 'http://127.0.0.1:1086' | |
# temporary | |
$env:HTTP_PROXY = $proxy | |
$env:HTTPS_PROXY = $proxy | |
# forever | |
# [System.Environment]::SetEnvironmentVariable("HTTP_PROXY", $proxy, "User") | |
# [System.Environment]::SetEnvironmentVariable("HTTPS_PROXY", $proxy, "User") | |
Write-Host "`n OPEN powershell proxy channel!`n" | |
} | |
function Clear-Proxy | |
{ | |
# temporary | |
Remove-Item env:HTTP_PROXY | |
Remove-Item env:HTTPS_PROXY | |
# forever | |
# [Environment]::SetEnvironmentVariable('http_proxy', $null, 'User') | |
# [Environment]::SetEnvironmentVariable('https_proxy', $null, 'User') | |
Write-Host "`n CLOSE powershell proxy channel!`n" | |
} | |
Set-Alias proxy Set-Proxy | |
Set-Alias noproxy Clear-Proxy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment