1

I trying to make a HTTPS request with the Invoke-WebRequest cmdlt:

Invoke-WebRequest -Uri "https://www.google.de" -Method GET -TimeoutSec 5

But executing this codes always ends up in a timeout. I also find this and this, which seems to be similar problems. But the mentioned workarounds wont work.

What I am doing wrong?

Community
  • 1
  • 1
Karl Nickel
  • 188
  • 1
  • 2
  • 10
  • That text worked for me with powershell 3.0. Got return code 200 and applicable parameters. Silly question but you can browse to this site from the computer you are testing from? perhaps try another computer. – Matt Aug 17 '14 at 14:02
  • Matt: What happens, if you run the code again and again? Do you get always a valid response? I am asking because sometimes I get a valid response - but only once. If I run the code again it results in a timeout. I can browse the HTTPS sites. And for HTTP sites the code always works as expected. Only HTTPS requests results in this strange behaviour... – Karl Nickel Aug 17 '14 at 15:57
  • Hmm... interesting. I just ran this `(1..20 | %{Invoke-WebRequest -Uri "https://www.google.de" -Method GET -TimeoutSec 5} | ?{$_.StatusCode -eq 200} | Measure-Object).Count` and the the output of 20. ran it several times – Matt Aug 17 '14 at 18:11
  • 1
    Given this is https, are credentials required i.e. do you need an authenticated session? – Keith Hill Aug 17 '14 at 21:02
  • @Matt I ran the code in another network (at work) and there it works. So I guess my network at home or the configuration of my Windows 7 in combination with my network causes this strange behaviour. The big question is: Where is the fish? – Karl Nickel Aug 18 '14 at 07:44
  • @KeithHill Authentication is not required. It's just a "simple" HTTPS request... – Karl Nickel Aug 18 '14 at 07:48
  • FYI `Invoke-WebRequest -Uri "https://www.google.de" -Method GET -TimeoutSec 5` works on V4. – Keith Hill Aug 18 '14 at 14:25

1 Answers1

0

Hm, strange. Now I have some time to debug this problem and I can't reproduce it. All HTTPS requests works as expected. Weird. Anyway... Thank you @Matt + @KeithHill for supporting me!

Karl Nickel
  • 188
  • 1
  • 2
  • 10