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

3
  • 1
    Why did you write version 5.0 in the title, 5.1 in the question and added tag powershell-2.0 ? Commented Jun 29, 2022 at 12:10
  • You mean something like this or this ? Commented Jun 29, 2022 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 Commented Jun 29, 2022 at 14:42

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.