1

How to bypass the default proxy in Windows while accessing a locally accessible URL?

By default the Invoke-WebRequest powershell cmdlet is using the default proxy server. In my setup the proxy allows only certain URLs and the locally accessible URL is not in that list.

Is there a way to bypass the proxy? I can add the URL to the proxy allowed list but I don't want to do that.

Thanks for the attention.

0

1 Answer 1

2

You can programmatically bypass proxy for local addresses and even return the old bypass list after you are done.

My function proxy will let you do that. Add your domain or server name or its IP address to override list:

   $p = proxy
   $p.Override += "*.domain.com" 
   $p | proxy
   Invoke-WebRequest ...
   #you could return old override here.

Otherwise, I think this should work:

 $proxy = new-object System.Net.WebProxy
 Invoke-WebRequest -Proxy $proxy ...
Sign up to request clarification or add additional context in comments.

2 Comments

Will it break the applications that depend on the proxy while this is running? It didn't look so.
No , the later call is local only.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.