首先打开%USERPROFILE%\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
通过可以通过code $PROFILE
然后添加下面代码到这个文件
function mSet-Proxy {
param (
[int]$Port = 7890,
[string]$IP = "localhost"
)
$proxy = "http://$IP`:$Port"
[System.Net.WebRequest]::DefaultWebProxy = New-Object System.Net.WebProxy($proxy)
[System.Net.WebRequest]::DefaultWebProxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
Write-Output "Proxy set to: $proxy"
}