powershellpowershell-5.0powershell-v5.1

Is there a way to fetch Response header for InvokeRest Method of Powershell Version 5


How can I fetch Response header for InvokeRest Method of Powershell Version 5, For Powershell version 6 -ResponseHeadersVariable is available , Is there any way to do it in powershell version 5. I am unable to find any way to do it.


Solution

  • I don't think there is a way to get response headers of Invoke-RestMethod in v5 but you can easily replace that with something like

    $headers = Invoke-WebRequest 'example.com' | select headers

    Adding some context of your scenario can help to suggest more suitable approach.