Invoke-WebRequest Proxy Bypass

前端 未结 1 1694
难免孤独
难免孤独 2021-01-15 20:47

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

By default the Invoke-WebRequest powershell cmdlet is using the

1条回答
  •  -上瘾入骨i
    2021-01-15 21:15

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

    0 讨论(0)
提交回复
热议问题