Can someone explain what I'm missing. I'm trying to do a simple PS script running remotely on the monitored via Invoke-Command. The script is just testing a web URL for availability. However, the script always shows as In Error (x days) and it never sends an OK alert even though I'm trying to tell it to do that. Here's my code: NOTE: please swap a usable URL as I have XXX'ed the real URL. $mon.FireActions = $True $mon.Details = "" $mon.SetMonitorStatus($mon.msOK) $Server = $mon.computername $Result = Invoke-Command -computername $Server -ScriptBlock { Try { (Invoke-WebRequest -uri "https://api-xxxxxx.duosecurity.com/auth/v2/ping").StatusCode } Catch { $($.Exception.Response.StatusCode.Value_) }} If ($Result -eq 200) #200 is an OK response { $mon.Details = "Duo API Website is available on $Server" #$mon.FireActions = $True #Commented out, no change $mon.SetMonitorStatus($mon.msOK) #Set to OK status } Else # Any other response is an Error and should throw an Alert { $mon.Details = "Duo API Website is not available on $Server. The error code is: " + $Result $mon.SetMonitorStatus($mon.msError) #Set to Alert status #$mon.FireActions = $True #Commented out, no change } asked 11 May '21, 18:08 ashmite |