In developing some scripts recently I discovered that the Invoke-RestMethod cmdlet (in PowerShell version 5 at least) doesn’t provide the values of the response headers. The workaround I had to use was to instead se the Invoke-WebRequest method.
The only inconvenience to be aware of is that the Invoke-RestMethod cmdlet handles the conversion of the request to JSON for you and is very easy to then use as an object in Powershell. The Invoke-WebRequest method requires some additional coding to get the data how you want it
$WebResponse = Invoke-WebRequest -Method GET -Uri $Uri
$ResponseData = $WebResponse.content | ConvertFrom-Json
It makes sense as the purposes of each method are different, however definitely one to be aware of. Also it seems in PowerShell 7.2 there is a new parameter on the Invoke-RestMethod named ResponseHeadersVariable that allows you to get the value of the response headers.