PowerShell Get-PackageProvider拒绝使用代理问题求助
问题描述
我已查阅过该问题的相关帖子,这类问题通常与代理设置和/或TLS1.2配置有关。我已完成这两项配置,并尝试了各种方式设置代理,但流量仍走直连(DIRECT)。
当前WinHTTP代理设置
PS C:\Windows\system32> netsh winhttp show proxy Current WinHTTP proxy settings: Proxy Server(s) : proxy.here.com:1234 Bypass List : (none)
脚本及执行输出
脚本内容
$proxy = 'http://proxy.here.com:1234' [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 [system.net.webrequest]::defaultwebproxy = new-object system.net.webproxy($proxy) [system.net.webrequest]::defaultwebproxy.credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials [system.net.webrequest]::defaultwebproxy.BypassProxyOnLocal = $true $env:http_proxy = "http://proxy.here.com:1234" $env:https_proxy = "http://proxy.here.com:1234" Get-PackageProvider -Name NuGet -ErrorAction 'SilentlyContinue' -Force -Verbose
执行输出
VERBOSE: No match was found for the specified search criteria and provider name 'NuGet'. Try 'Get-PackageProvider -ListAvailable' to see if the provider exists on the system. VERBOSE: Finding the package 'Bootstrap::FindPackage' 'NuGet','','0.0.0.1','''. WARNING: MSG:UnableToDownload «https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409» «» VERBOSE: Cannot download link 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409', retrying for '2' more times. WARNING: Unable to download from URI 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409' to '' VERBOSE: Cannot download link 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409', retrying for '2' more times. VERBOSE: Cannot download link 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409', retrying for '1' more times. VERBOSE: Cannot download link 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409', retrying for '1' more times. VERBOSE: Cannot download link 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409', retrying for '0' more times. WARNING: Unable to download the list of available providers. Check your internet connection. VERBOSE: Cannot download link 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409', retrying for '0' more times.
流量异常情况
我监控了主机的所有出站流量,未发现访问上述URL的请求,反而看到一系列对https://onegetcdn.azureedge.net/providers/providers.masterList.feed.swidtag的调用——这些请求完全不走代理,直接直连并被防火墙拦截。我尝试了各种方法都无法强制该流量走代理。
更反常的是,在同一个PowerShell会话中,用Invoke-WebRequest访问这个URL却能正常通过代理:
PS C:\Windows\system32> Invoke-WebRequest -Verbose https://onegetcdn.azureedge.net/providers/providers.masterList.feed.swidtag VERBOSE: GET https://onegetcdn.azureedge.net/providers/providers.masterList.feed.swidtag with 0-byte payload VERBOSE: received 1847-byte response of content type text/plain; charset=utf-8 StatusCode : 200 StatusDescription : OK Content : <?xml version="1.0" encoding="utf-8"?>
内容的提问来源于stack exchange,提问作者klaypigeon
相关产品推荐
相关产品推荐

