I am currently in Powershell V5.1 and would like to bypass Internet Explorer proxy on a Invoke-RestMethod command.
In Powershell V6, there is the -NoProxy option that indicates that the cmdlet will not use a proxy to reach the destination. This is to bypass the proxy configured in Internet Explorer and this is exactly what I want to do.
In Powershell V6, the code would be something like:
$Result = Invoke-RestMethod -Uri $url -NoProxy
Any workaround in V5.1 ?
Thanks, Philippe
As an alternative, but I think postanote has a great answer. How about dipping into .net? And going a level deeper than typical these days, so instead of using .net's HttpClient using WebRequest:
I haven't tested extensively if this bypasses a proxy (my corporate policy will make this tricky to test), but this c# question suggests it should do: How to remove proxy from WebRequest and leave DefaultWebProxy untouched
Of course you'd loose some of the pipelining magic in PowerShell, but you could wrap it easily enough, being careful of socket usage if your using this under heavy load.