
Community Archive (Customer) asked a question.
HTTP Status Code check with Powershell
$statusCode = (invoke-webrequest -uri "http://google.com" -UseBasicParsing -TimeoutSec 20).statuscode
if($StatusCode -ne 200)
{
$resultText = 1
$Context.SetResult($resultText, "Check failed, was not equal to 200");
}
else{
$resultText = 0
$Context.SetResult($resultText, "Check was successful");
}
Might be able to turn this into a content check using select-string.
I changed this just a little to add a variable at the top to hold the URL to check instead of in the Invoke-WebRequest ..