powershell http get not use proxy

2019-04-15 15:49发布

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条回答
beautiful°
2楼-- · 2019-04-15 16:23

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)
查看更多
登录 后发表回答