Windows tasks with Cronwatch
This check expects a Windows task every day. The PowerShell snippet runs your script and reports success or failure with Invoke-RestMethod, which ships with Windows.
- Create the check: daily with one hour of grace.
- Copy the PowerShell snippet into the script your scheduled task runs.
- In Task Scheduler, make sure the task runs whether the user is logged on or not, so it keeps running after a logoff.
- Run the task once from Task Scheduler and confirm the check turns UP.
What to know
Task Scheduler reports "The operation completed successfully" for tasks that never did their job, and its history is disabled by default on many machines. Common silent failures are a changed password on the account that runs the task, a task set to run only when the user is logged on, and a machine that was asleep at the scheduled time.
Reporting from inside the script avoids all of that: if the ping does not arrive, something stopped the work, whatever the reason. The snippet checks $? after your script and calls /fail when it failed, so errors alert you immediately.
On servers behind a proxy, make sure PowerShell can reach the internet, or pass the proxy with -Proxy on Invoke-RestMethod. Add -TimeoutSec 10 if your script must never wait on the network, so monitoring can never hold up the work it is watching.
Updated · Cosmovex
Questions
Why does my scheduled task not run?
Typical causes: the account password changed, the task only runs when the user is logged on, the machine was asleep, or the action points at a path that moved.
Does this need any software on the PC?
No. Invoke-RestMethod is built into PowerShell.
Can I report failures?
Yes. The snippet calls the /fail URL when the script reports an error, which alerts you immediately.
Is it free?
Yes, for up to 3 checks with email alerts.
The free plan covers everything on this page. Cronwatch Pro ($5/mo, billed monthly) is described on the Cronwatch page.