Skip to content

Instantly share code, notes, and snippets.

@canbingzt
Created April 18, 2025 05:18
Show Gist options
  • Select an option

  • Save canbingzt/e47909cca705c0b42515b7a569f600f1 to your computer and use it in GitHub Desktop.

Select an option

Save canbingzt/e47909cca705c0b42515b7a569f600f1 to your computer and use it in GitHub Desktop.
function proxy {
$env:http_proxy = "http://127.0.0.1:7890"
$env:https_proxy = "http://127.0.0.1:7890"
[System.Net.WebRequest]::DefaultWebProxy = New-Object System.Net.WebProxy ("http://127.0.0.1:7890")
Write-Host "Proxy enabled: http://127.0.0.1:7890" -ForegroundColor Green
}
function unproxy {
$env:http_proxy = $null
$env:https_proxy = $null
[System.Net.WebRequest]::DefaultWebProxy = $null
Write-Host "Proxy disabled" -ForegroundColor Yellow
}
function check-proxy {
if ($env:http_proxy -or $env:https_proxy) {
Write-Host "Current proxy settings:" -ForegroundColor Cyan
Write-Host "HTTP Proxy: $env:http_proxy"
Write-Host "HTTPS Proxy: $env:https_proxy"
} else {
Write-Host "No proxy is currently set." -ForegroundColor Cyan
}
}
Remove-Item alias:curl
proxy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment