我很难修改PsGet以通过代理工作。我使用此
替换了PsGet.psm1上的每个$ client初始化# $client = (new-object Net.WebClient)
$proxyAddr = (get-itemproperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings').ProxyServer
$proxy = new-object System.Net.WebProxy
$proxy.Address = $proxyAddr
$proxy.useDefaultCredentials = $true
$client = new-object system.net.WebClient
$client.proxy = $proxy
但我仍然在WebClient请求期间继续获取DotNetMethodException。
答案 0 :(得分:10)
试一试。使用[System.Net.WebRequest]::DefaultWebProxy
代替注册表阅读。
$wc = New-Object System.Net.WebClient
$wc.Headers.Add("User-Agent","Mozilla/4.0+")
$wc.Proxy = [System.Net.WebRequest]::DefaultWebProxy
$wc.Proxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
$wc.DownloadString("https://github.com/chaliy/psget/raw/master/PsGet/PsGet.psm1")