Skip to content

Instantly share code, notes, and snippets.

@qmdx00
Created April 18, 2020 04:19
Show Gist options
  • Save qmdx00/04c88d5172b2b50252cd2bc7c0a8257f to your computer and use it in GitHub Desktop.
Save qmdx00/04c88d5172b2b50252cd2bc7c0a8257f to your computer and use it in GitHub Desktop.
windows powershell proxy config
# 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