I'm having a hard time modifying PsGet to work though a proxy. I replaced every $client initialization on PsGet.psm1 with this
# $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
but I still keep getting the DotNetMethodException during the WebClient request.
Give this a try. Use [System.Net.WebRequest]::DefaultWebProxy
instead of the registry read.
$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")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With