Similar to this question here I am trying to monitor if a set of website links are up and running or not responding. I have found the same PowerShell script over the Interne
You can try this:
function Get-UrlStatusCode([string] $Url) { try { (Invoke-WebRequest -Uri $Url -UseBasicParsing -DisableKeepAlive).StatusCode } catch [Net.WebException] { [int]$_.Exception.Response.StatusCode } } $statusCode = Get-UrlStatusCode 'httpstat.us/500'