How to check if response header contains certain headers powershell

Question:

I’m using iwr to make a request like so:

This gets me the headers which looks something like this:

How do I check if the headers contain this:

I tried

But this returns false for some reason. Is there a way to do this?

Answer:

Headers returned from Invoke-Webrequest is a IDictionary.
You can test by retrieving the value of the key you need.

Source:

How to check if response header contains certain headers powershell by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply