powershell http get not use proxy

2019-04-15 15:29发布

问题:

I have script to GET HTTP content and I need baypass Proxy (connect directly to webserver IP). Is it possible without changing registers in Windows?. This code is going through proxy defined in system. Thanks for advice

Best regards.

$url='https://10.10.10.10/check';
$webClient = new-object System.Net.WebClient;
$output = $webClient.DownloadString($url)

回答1:

According to the documentation you have to set the proxy to a blank proxy instance. Try this:

$url = "https://10.10.10.10/check"
$webClient = New-Object System.Net.WebClient
$webClient.Proxy = [System.Net.GlobalProxySelection]::GetEmptyWebProxy()
$output = $webClient.DownloadString($url)