← All guides
Guide · Windows
Monitor a Windows Scheduled Task
No install needed. Invoke-RestMethod is built into PowerShell (and curl ships with Windows 10/11 too), so a scheduled task can check in with one line.
1. Create a check
Create a check in Mortemain and copy its unique ping URL:
your ping URL
https://ping.mortemain.com/your-check-uuid
2. Ping from your script
Wrap the work in try/catch: ping the check on success, and the /fail endpoint on any error so a crash forces the check down immediately.
backup.ps1
$Url = "https://ping.mortemain.com/your-check-uuid" try { # ... your job ... Backup-SqlDatabase -ServerInstance "localhost" -Database "prod" -BackupFile "D:\bak\prod.bak" Invoke-RestMethod $Url -TimeoutSec 10 # success } catch { Invoke-RestMethod "$Url/fail" -TimeoutSec 10 # failure throw }
3. Wire it to Task Scheduler
Point the task's action at the script (Program: powershell.exe, arguments below), or ping inline without a script file:
Task Scheduler action
# run the script powershell -NoProfile -ExecutionPolicy Bypass -File "C:\jobs\backup.ps1" # …or inline: ping only if the job succeeded (irm = Invoke-RestMethod) powershell -NoProfile -Command "C:\jobs\backup.ps1; if (`$?) { irm https://ping.mortemain.com/your-check-uuid }"
Test it
Run Invoke-RestMethod https://ping.mortemain.com/your-check-uuid once by hand. The check flips to up in a second or two. Skip a run past its window and you'll get the down alert.