Last updated on 2021-01-13
I had to do a lot of debugging with PowerShell based WebRequest’s the last few days.
One issue I had: I saved the Cookie that a call returned. Now the Call returned two cookies instead of one, and my call didn’t handle that correctly.
To be honest: My mistake, my code was terrible and had no error handling! But it took me a while to find the root cause for this issue!
Mainly because the second cookie wasn’t from the hostname (FQDN) I called; it was from another host within the same domain. Not a terrible thing, but it just took a little bit longer to find and isolate that issue.
I used a snippet I found a very long time ago and extracted the cookies based on the hostname:
Also part of my default PowerShell Repository.