8

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?

2
  • Can you try to full qualify the URI like "https ://heise.de" Commented Mar 1, 2017 at 7:50
  • same error, also tryed proxy IP instead of name Invoke-WebRequest -Uri ht"tps://heise.de -Proxy 192.168.222.222:8080 -ProxyCredential $mycredentials Commented Mar 1, 2017 at 8:53

1 Answer 1

18

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.