Skip to content

Instantly share code, notes, and snippets.

@Internet-viewer
Forked from 499978920/profile.ps1
Created January 20, 2023 12:50
Show Gist options
  • Select an option

  • Save Internet-viewer/6d0909add8f71775d38ccba8154bba86 to your computer and use it in GitHub Desktop.

Select an option

Save Internet-viewer/6d0909add8f71775d38ccba8154bba86 to your computer and use it in GitHub Desktop.
[powershell proxy] power shell 走代理 #powershell #proxy
# path
# C:\Program Files\PowerShell\7
function set_proxy_variable {
$proxy = 'http://127.0.0.1:10809'
# 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 unset_proxy_variable {
# 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_variable
Set-Alias unproxy unset_proxy_variable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment