Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PowerShell - Invoke-WebRequest - Relative URI not supported when using -Proxy

i try to access websites through a proxy.

I tried the following:

$mycredentials = Get-Credential
Invoke-WebRequest -Uri heise.de -Proxy proxySrv -ProxyCredential $mycredentials

Invoke-WebRequest : Dieser Vorgang wird für einen relativen URI nicht unterstützt. In Zeile:1 Zeichen:1 + Invoke-WebRequest -Uri heise.de -Proxy proxySrv -Prox ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Invoke-WebRequest], InvalidOperationException + FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

Translation of error to English:

Invoke-WebRequest : This operation is not supported for a relative URI. In line: 1 character: 1 + Invoke-WebRequest -Uri heise.de -Proxy proxySrv -Prox ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Invoke-WebRequest], InvalidOperationException + FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

If I attempt the command without the Proxy setting I get an error from our proxy.

Can you help figure out why?

like image 638
Steakschen Avatar asked Mar 01 '17 07:03

Steakschen


1 Answers

The relative URL being complained about is the proxy URL, not the target URL. Replace:

-Proxy 192.168.222.222:8080

with

-Proxy http://192.168.222.222:8080

(or https if appropriate) and you should find the error goes away

like image 76
Chris F Carroll Avatar answered Sep 17 '22 23:09

Chris F Carroll