Go to All Forums

Monitor Windows Scheduled Tasks

It would be extremely helpful in a server monitor to be able to monitor scheduled tasks.


Useful thresholds on scheduled tasks that I can think of would be

Running Status => x minutes/hours/days

Disabled Status => x minutes/hours/days

Last run time => x minutes/hours/days ago

Error code returned on last run - yes/no

Error code returned on last run => x runs



Like (9) Reply
Replies (18)

You can use custom plugin to monitor the scheduled tasks.

Please find attached ScheduledTask.zip. Please unzip this file and mention the name of the scheduled task to be monitored in the file "ScheduledTask.ps1" and copy paste the ScheduledTask folder into the plugins folder.
Eg: C:\Program Files (x86)\Site24x7\WinAgent\monitoring\Plugins

The scheduled task plugin contains the following metrics :

  • state_value: Current state of the task
  • numberOfMissedRuns : Number of task schedules that were missed from running
  • lastRunBefore : Time of previous schedule tasks performed
  • author : Task's owner
  • state : Description of the task state
  • lastRunTime : Previous date and time of the task scheduled
  • createdon : Task created time
  • errorCode : Error code of previous scheduled tasks


Size: 1.88 KB
Like (0) Reply

Thank you.  If we want to monitor a bunch of scheduled tasks on a particular server would we setup an additional PS job for each or is there a way to create a list of tasks in one plugin?

Like (0) Reply


For each server added, you will be able to monitor one plugin and each plugin can have up to 25 attributes. And, the Scheduled Task plugin that we have provided has around eight attributes. So if you would want to add and monitor multiple job tasks with the same metrics as given in the Scheduled Task plugin, it would exceed the default attribute limit. 

However, if you wish to know and monitor only the name and status of a scheduled task, it is possible to add them as a single plugin monitor.

Please let us know if this helps.


Like (0) Reply

Thanks.  It appears that the powershell script uses the command Get-ScheduledTask which doesn't work in windows 2008 R2, which is most of our environment. Do you perhaps have an example that works in a batch file and uses schtasks which does work in windows 2008 R2.

Like (0) Reply

You can write a custom plugin to monitor the scheduled tasks. Please find attached ScheduledTask.zip. We have used schtasks command to get data. it will remove the Get-ScheduledTask dependency. So this plugin will work fine in Windows 2008 R2.

  1. Unzip this file
  2. Mention the name of the scheduled task to be monitored in "ScheduledTask.ps1".
  3. Now, copy paste the ScheduledTask folder into the plugins folder.
    Eg: C:\Program Files (x86)\Site24x7\WinAgent\monitoring\Plugins

Performance Metrics:

This plugin contains the following metrics:

  • lastRunBefore : Time of the previous schedule task that was performed
  • author : Task's owner
  • Status : Current state of the task
  • lastRunTime : Date and time of the previous scheduled task
  • Start_Date : The time when the task was initiated
  • errorCode : Error code of the previous scheduled task

Hope this helps. Let us know for further queries.


Size: 2.08 KB
Like (0) Reply


I am attempting to use this on Server 2012 R2, and not seeing the correct stats being returned. 

Has there been an updates to this, or would this be unique to my environment?



Like (0) Reply


Could you please share the logs to support@site24x7.com to analyze the issue? 

It would be helpful for us to assist you better.



Like (0) Reply



However, if you wish to know and monitor only the name and status of a scheduled task, it is possible to add them as a single plugin monitor."


Could you please help doing this ?

Like (0) Reply


We would like to know to how many tasks you would be monitoring. Because we have limitation on the plugin metrics, i.e., a maximum of 25 attributes only.  

So please let us know the count of the scheduled tasks you would like to monitor, and based on that we shall give you suggestions.





Like (0) Reply

Does this utility also send alert email in case schedule task is failed or did not run?

Like (0) Reply


Using this plugin, you can get alerts for scheduled task failures by setting a threshold for the metric "errorCode". If the metric errorCode is 0, it means the previously scheduled task was completed successfully; if the errorCode is greater than 0, it means the previously scheduled task failed.

This plugin script does not have the support to alert when the scheduled tasks do not run. We are currently working on providing in-depth Windows Scheduled Tasks Monitoring and we shall include this metric in that.

Hope this helps. Let us know for further queries if any.

Happy Monitoring!


Like (0) Reply

Reviving this thread.

Receiving an error in Site24x7 that the plug-in was not executed propely.

Running the PowerShell script manually results in -

PS C:\Program Files (x86)\Site24x7\WinAgent\monitoring\Plugins\ScheduledTask> C:\Program Files (x86)\Site24x7\WinAgent\monitoring\Plugins\ScheduledTask\ScheduledTask.ps1
Get-ScheduledTaskInfo : The system cannot find the file specified.
At C:\Program Files (x86)\Site24x7\WinAgent\monitoring\Plugins\ScheduledTask\ScheduledTask.ps1:79 char:13
+ $taskInfo = Get-ScheduledTaskInfo -TaskName $taskName
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (PS_ScheduledTask:Root/Microsoft/...S_ScheduledTask) [Get-ScheduledTaskInfo], CimException
+ FullyQualifiedErrorId : HRESULT 0x80070002,Get-ScheduledTaskInfo

You cannot call a method on a null-valued expression.
At C:\Program Files (x86)\Site24x7\WinAgent\monitoring\Plugins\ScheduledTask\ScheduledTask.ps1:82 char:1
+ $data.Add("lastRunTime",$lastRunTime.ToString())
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull

New-TimeSpan : Cannot bind parameter 'Start' to the target. Exception setting "Start": "Cannot convert null to type "System.DateTime"."
At C:\Program Files (x86)\Site24x7\WinAgent\monitoring\Plugins\ScheduledTask\ScheduledTask.ps1:88 char:34
+ $timespan = NEW-TIMESPAN –Start $lastRunTime –End $timenow
+ ~~~~~~~~~~~~
+ CategoryInfo : WriteError: (:) [New-TimeSpan], ParameterBindingException
+ FullyQualifiedErrorId : ParameterBindingFailed,Microsoft.PowerShell.Commands.NewTimeSpanCommand

You cannot call a method on a null-valued expression.
At C:\Program Files (x86)\Site24x7\WinAgent\monitoring\Plugins\ScheduledTask\ScheduledTask.ps1:90 char:1
+ $timediff = $timespan.Days.ToString() + " Days "+ $timespan.Hours.ToS ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull

Like (0) Reply

Adding - it appears the PS1 output results are correct, but still get the errors above when executing.

"heartbeat": "True",
"displayname": "Monitor Task - Throttled Disconnects Processor",
"version": "1",
"data": {
"state_value": 3,
"numberOfMissedRuns": null,
"lastRunBefore": null,
"author": "XXXXX",
"state": "Ready",
"errorCode": null,
"createdon": "2017-05-15T11:51:26.551516"

Like (0) Reply


Can you please share your agent logs with support@site24x7.com? That would help us analyze the issue further.






Like (0) Reply


We've introduced the .cfg file to the Windows Scheduled Tasks plugin. You can now make changes to the ScheduledTask.cfg file and monitor metrics for multiple scheduled tasks as separate monitors.

Here are the metrics the plugin monitor tracks:

lastRunBefore: Time of Previous Schedule task performed

author: Task's owner

Status: Current state of the task

lastRunTime: Previous Datetime of Task Scheduled

Start_Date: Task Started time

errorCode: Error code of Previous Scheduled task



Download and install the latest version of the [Site24x7 Windows agent] (https://www.site24x7.com/app/client#/admin/inventory/add-monitor) in the server where you plan to run the plugin. 


1. Visit our GitHub repository and download the .ps1 file and the .cfg file.


2. Modify the .cfg file with the task name to monitor the particular task:

For example:


Note: To fill in the task name in the .cfg file, add the location of the task you want to monitor from the General tab of Windows Task Scheduler followed by a slash and the task name.

3. To monitor multiple tasks, modify the .cfg file accordingly.

Here's an example below:


taskName=\Microsoft\Windows\AppId\Work Room

3. Create a folder ScheduledTask under Site24x7 Windows plugins directory and place the plugin files ScheduledTask.ps1 and ScheduledTask.cfg inside the folder.


The agent will automatically execute the plugin within five minutes and send performance data to the Site24x7 data center.

Feel free to reply to this thread for any clarification.

Happy monitoring!

Like (0) Reply

Hello guys!


I'm trying to run this script on a Windows Server 2019 and getting some errors... does it run on WS 2019?

Script has 151 lines

and the .cfg is





PS C:\scripts> .\ScheduledTasks.ps1
Get-ScheduledTaskInfo : Cannot validate argument on parameter 'TaskName'. The argument is null or empty. Provide an argument that is not null or empty, and
then try the command again.
At C:\scripts\ScheduledTasks.ps1:87 char:31
+ $task2= Get-ScheduledTaskInfo $taskName
+ ~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Get-ScheduledTaskInfo], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Get-ScheduledTaskInfo

Like (0) Reply

Hi Gerardo,
The error is showing up because the path of the task has not been provided in the command.
To fix the error, please execute the following script, which includes the path of the task.
For example, if \API_Clipboard is the path, execute the below command:
    .\ScheduledTasks.ps1 -taskName "\API_Clipboard"

For more details on the installation of this plugin, please check the link below:
Like (0) Reply



I fixed that part on the server side, and I can run the .ps1 successfully 

But the monitor on the site24x7 is not recognizing it.


Please see the attachments.


kind regards,



Like (0) Reply

Was this post helpful?