代码语言:javascript 复制 只对当前窗口有效 $proxyUrl = ":proxyserver_port" $proxy = New-Object System.Net.WebProxy $proxy.Address = $proxyUrl [System.Net.WebRequest]::DefaultWebProxy = $proxy 列出代理 [System.Net.WebRequest]::DefaultWebProxy 验证效果 (Invoke-WebRequest '' -UseBasicParsing).Content (Invoke-WebRequest '' -UseBasicParsing).Content (Invoke-WebRequest '' -UseBasicParsing).Content (Invoke-WebRequest '' -UseBasicParsing).Content (Invoke-WebRequest '' -UseBasicParsing).Content (Invoke-WebRequest '' -UseBasicParsing).Content 代码语言:javascript 复制 只对当前窗口有效 $proxyUrl = ":proxyserver_port" $ENV:HTTP_PROXY = $proxyUrl $ENV:HTTPS_PROXY = $proxyUrl 列出代理 ls env:*|findstr PROXY 验证效果 $proxyUrl = ":proxyserver_port" Invoke-WebRequest -Uri "" -Proxy $proxyUrl (Invoke-WebRequest '' -UseBasicParsing -Proxy $proxyUrl).Content (Invoke-WebRequest '' -UseBasicParsing -Proxy $proxyUrl).Content (Invoke-WebRequest '' -UseBasicParsing -Proxy $proxyUrl).Content (Invoke-WebRequest '' -UseBasicParsing -Proxy $proxyUrl).Content (Invoke-WebRequest '' -UseBasicParsing -Proxy $proxyUrl).Content (Invoke-WebRequest '' -UseBasicParsing -Proxy $proxyUrl).Content 清空代理 $ENV:HTTP_PROXY="" $ENV:HTTPS_PROXY="" ls env:*|findstr PROXY 图形界面设置代理: 运行inetcpl.cpl → 连接 → 局域网设置 → 代理服务器(地址和端口) 代码语言:javascript 复制 $proxyServer = "proxyserver_ip:proxyserver_port" $registryPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" # Proxy Enable : Set 'ProxyEnable' to 1 to enable proxy, set 0 to disable proxy Set-ItemProperty -Path $registryPath -Name ProxyEnable -Value 1 # Proxy Server : Set 'ProxyServer' to your proxy address and port (e.g., "192.168.1.1:8080") Set-ItemProperty -Path $registryPath -Name ProxyServer -Value $proxyServer # Apply proxy settings to all protocols: remove any exceptions that may exist Set-ItemProperty -Path $registryPath -Name ProxyOverride -Value "" 列出代理 [System.Net.WebProxy]::GetDefaultProxy() Get-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' | Select-Object ProxyServer, ProxyEnable 验证效果 (Invoke-WebRequest '' -UseBasicParsing).Content (Invoke-WebRequest '' -UseBasicParsing).Content (Invoke-WebRequest '' -UseBasicParsing).Content (Invoke-WebRequest '' -UseBasicParsing).Content (Invoke-WebRequest '' -UseBasicParsing).Content (Invoke-WebRequest '' -UseBasicParsing).Content 临时禁止代理: Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' ProxyEnable -value 0 临时启用代理: Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' ProxyEnable -value 1 彻底干掉代理: Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' ProxyEnable -value 0 $proxyServer = "" $registryPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" Set-ItemProperty -Path $registryPath -Name ProxyServer -Value $proxyServer Set-ItemProperty -Path $registryPath -Name ProxyOverride -Value "" 原创声明:本文系作者授权腾讯云开发者社区发表,欧博allbet未经许可,不得转载。 如有侵权,欧博百家乐请联系 cloudcommunity@tencent.com 删除。 windows windows server 云服务器 原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。 如有侵权,请联系 cloudcommunity@tencent.com 删除。 (责任编辑:) |