0

I want to get the Satuscode when the HTTP returns code 200, i know there is way to use try , Catch but thats to catch error StatusCode, what is the way to catch the sucessfull status code 200 using Invoke-Restmethod in Powershell 5.1 ?

Any help is appreciated

wehelpdox
  • 339
  • 6
  • 16
  • 1
    Why did you write version 5.0 in the title, 5.1 in the question and added tag `powershell-2.0` ? – Theo Jun 29 '22 at 12:10
  • You mean something like [this](https://stackoverflow.com/a/65653074/9898643) or [this](https://stackoverflow.com/a/62453104/9898643) ? – Theo Jun 29 '22 at 12:17
  • $status = [int]$response.StatusCode only work for powershell7.0 and above , but it worked if i change it to Invoke-Webrequest instead of Restmethod – wehelpdox Jun 29 '22 at 14:42

0 Answers0