Nice and quick post here, mainly so I remember when I need it again, this is a quick sample which shows how to make a web call from PowerShell including a cookie.
Most old methods will suggest using the WebClient object but the new (well newer than the WebClient) Invoke-WebRequest commandlet is a much nicer, in my opinion.
It takes a bit of fooling around to get this up and running so wanted to share.
2 thoughts on “Powershell Invoke-WebRequest with a cookie”
why do you create and define $cookie, but add undefined $cookietype ?
Thanks, good spot it’s a typo in the script – I’ve updated it now.