Invoke-WebRequest Proxy Bypass

好久不见. 提交于 2019-12-08 06:19:29

问题


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.


回答1:


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 ...


来源:https://stackoverflow.com/questions/36662104/invoke-webrequest-proxy-bypass

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!