Skip to content

Instantly share code, notes, and snippets.

@499978920
Last active August 5, 2024 02:03
Show Gist options
  • Save 499978920/b67bc92a0c7a987f4e0dfb3b829b8ab7 to your computer and use it in GitHub Desktop.
Save 499978920/b67bc92a0c7a987f4e0dfb3b829b8ab7 to your computer and use it in GitHub Desktop.
[powershell proxy] power shell 走代理 #powershell #proxy
# path
# C:\Program Files\PowerShell\7
function set_proxy {
$proxy = 'http://127.0.0.1:7890'
# 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 {
# 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 unproxy unset_proxy
function Invoke-FileHashMD5
{
param( $File )
certutil -hashfile $File MD5
}
function Invoke-FileHashSHA1
{
param( $File )
certutil -hashfile $File SHA1
}
Set-Alias -Name md5 -Value "Invoke-FileHashMD5"
Set-Alias -Name sha1 -Value "Invoke-FileHashSHA1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment