PowerShell, Web Requests, and Proxies

前端 未结 6 1147
遇见更好的自我
遇见更好的自我 2020-12-12 17:36

When making a simple web request is there a way to tell the PowerShell environment to just use your Internet Explorer\'s proxy settings?

My proxy settings are contro

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-12 17:45

    I know this is really really old, but there's a right way and so few people seem to know it. The below will figure out what the proxy is for the URI that you're interested in and use it.

    $uri = "http://www.google.com"
    invoke-webrequest -ProxyUseDefaultCredentials -proxy (new-object System.Net.WebClient).Proxy.GetProxy($uri).AbsoluteUri $uri
    

提交回复
热议问题