user1728814
user1728814

Reputation: 109

Bypass system proxy settings in PowerShell HTTP GET

I have script to GET HTTP content and I need bypass proxy (connect directly to webserver IP).

Is it possible without changing registry 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)

Upvotes: 4

Views: 10811

Answers (1)

Ansgar Wiechers
Ansgar Wiechers

Reputation: 200293

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)

Upvotes: 6

Related Questions