# service-status.ps1 — status of named services. $Url = "YOUR_URL/services" $Watch = @("W3SVC", "MSSQLSERVER", "BITS") # services that should be running $Statuses = @{} $AnyStopped = $false foreach ($name in $Watch) { $svc = Get-Service -Name $name -ErrorAction SilentlyContinue if ($svc) { $running = $svc.Status -eq 'Running' $Statuses[$name] = @{ found = $true; status = "$($svc.Status)"; running = $running } if (-not $running) { $AnyStopped = $true } } else { $Statuses[$name] = @{ found = $false; status = "missing"; running = $false } $AnyStopped = $true } } $Body = (@{ hostname = $env:COMPUTERNAME services = $Statuses any_stopped = $AnyStopped }) | ConvertTo-Json -Compress -Depth 4 Invoke-RestMethod -Uri $Url -Method Post -Body $Body ` -ContentType "application/json" -TimeoutSec 15 | Out-Null