# status.ps1 — POST a self-reported severity to site1.erralert.com. # # Usage: # .\status.ps1 -Severity ok # .\status.ps1 -Severity warn -Summary "disk getting full" # .\status.ps1 -Severity crit -Summary "service down" # .\status.ps1 -Severity error -Summary "couldn't even probe" param( [Parameter(Mandatory=$true)] [ValidateSet('ok','warn','crit','error')] [string]$Severity, [string]$Summary = '' ) $Url = "YOUR_URL/$Severity" $Body = @{ hostname = $env:COMPUTERNAME } if ($Summary) { $Body['summary'] = $Summary } $Json = $Body | ConvertTo-Json -Compress try { Invoke-RestMethod -Uri $Url -Method Post -Body $Json ` -ContentType "application/json" -TimeoutSec 15 | Out-Null exit 0 } catch { Write-Error $_ exit 1 }