How to Configure Clustered Tasks with Windows Server 2012

How to Configure Clustered Tasks with Windows Server 2012

Rate This
  • Comments 21

Many customers use the Windows Task Scheduler to perform regularly scheduled maintenance tasks on their servers, to run audit checks, generate reports, and even updating application data caches. A task in the Windows Task Scheduler performs an action when a given trigger (condition) has been met.

In previous releases of Windows Server, you could create a task that was local to a single node (server) that was part of a Failover Cluster, but the Task Scheduler did not have any understanding of the entire cluster. Configuring and managing tasks on a on a large scale 32 or 64 Node Cluster can be more challenging than maintaining them on a single machine. Manually copying tasks from one machine to another can become time consuming and error prone. In Windows Server 2012, this experience is significantly improved as you can now use Clustered Scheduled Tasks for the tasks that you want to run on your cluster. There are three types of Clustered Scheduled tasks:

  •          Any Node: There is one instance enabled of the task in the cluster, hence the task only triggers in one machine. This task will be present in the cluster until it’s unregistered or the cluster is destroyed.
    Example: if you have a program that pulls information out of the cluster and sends out a report, you only need it to be run in one machine and you do not care which one. This can be an Any Node task.


  •          Resource Specific: There is one instance enabled of task which is bound to a resource in the cluster. The task will run on the same node as the resource.  So if the cluster resource is moved to another node, so is the task. Unlike an Any Node task, if this resource is removed so is the task.
    Example: if you have a physical disk resource and you want to defragment the disk every month. This is a good example for a Resource Specific task.


  •          Cluster Wide: There is one instance of the task enabled in each node of the cluster. In this case when the trigger is met, the action is executed in all nodes present at that time in the cluster that meet the condition of the trigger.
    Example: if you want to have a tool or set of tools to be opened when you login to any of the nodes, this is the kind of task you can add as a Cluster Wide task.

Managing Clustered Tasks using PowerShell:

Now let’s see how to configure and manage clustered tasks using PowerShell. There are four basic PowerShell commands available to configure, query or modify clustered tasks.




 Query cluster tasks.


 Register a cluster task.


 Update an already registered cluster task.


 Unregister a cluster task.


In Windows Server 2012, PowerShell commands from different modules are auto-loaded upon first use. It is important to note that the above PowerShell commands are available through TaskScheduler module. Notice that the cmdlets have the “Clustered” prefix as part of the noun in the cmdlet. If you try using the cmdlets without the clustered word in it you won’t be creating a clustered task, or querying the cluster for tasks – instead you’ll be using on a regular node (server) scoped task.


Need more information? Remember you can run any of the following from your PowerShell window:

  •          [name of the cmdlet] -?
  •          Get-help [name of the cmdlet] –full

Registering Cluster Task

In this first entry for clustered tasks we’ll show you how to create a Resource Specific task in 3 easy steps:

1. Pick your action

$action = New-ScheduledTaskAction – Execute C:\ClusterStorage\Volume1\myprogram.exe

This creates the action to be performed by my task. As you can see in the value for the Execute parameter my program is located on a Cluster Shared Volume (CSV) in my cluster which already makes it highly available to my cluster and accessible from all nodes.

2. Pick your trigger

$trigger = New-ScheduledTaskTrigger -At 13:00 –Daily

This creates the trigger that starts my task in the cluster. For this example I want to run my program every day at 13:00.

3. Register your task

Register-ClusteredScheduledTask –Cluster MyCluster –TaskName MyResourceSpecificTask –TaskType ResourceSpecific –Resource MyResourceName –Action $action –Trigger $trigger


Register-ClusteredScheduledTask –Cluster MyCluster –TaskName MyAnyNodeTask –TaskType AnyNode –Action $action –Trigger $trigger


Register-ClusteredScheduledTask –Cluster MyCluster –TaskName MyClusterWideTask –TaskType ClusterWide –Action $action –Trigger $trigger


And you are done. Your cluster now has a task that will run daily at 13:00.

Once you have your tasks registered you still might want to query it and even unregister it. To do that you can do the following:

Querying Cluster Task

The Get-ClusteredScheduledTask allows you to query the tasks in the cluster in the following ways:

  •          Tasks in the cluster
  •          Tasks of a certain type
  •          Task by its name

To query all cluster tasks

Get-ClusteredScheduledTask –Cluster MyCluster

To query all task of a type

Get-ClusteredScheduledTask –Cluster MyCluster –TaskType ResourceSpecific

To query a task by name

Get-ClusteredScheduledTask –Cluster MyCluster –TaskName MyResourceSpecificTask


Updating Cluster Task

After a task is registered, its actions and triggers can be modified independently. In this case we want to update the trigger so that instead of executing at 13:00 it executes at 23:00 once everyone is out of the office.


$trigger = New-ScheduledTaskTrigger -At 23:00 - Daily

Set-ClusteredScheduledTask –Cluster MyCluster –TaskName MyResourceSpecificTask –Trigger $trigger

Similarly if you want to update the action you can create a new action and assign it to the task.


How to view the values of the Trigger

To see the current values of the action and triggers, you go into the ‘TaskDefinition’ of your task. This task definition contains the Triggers and Actions. This is an example of how to see the triggers, and the output for the task after we have updated the task.

(Get-ClusteredScheduledTask -TaskName MyResourceSpecificTask).TaskDefinition.Triggers


Enabled            : True

EndBoundary        :

ExecutionTimeLimit :

Id                 :

Repetition         : MSFT_TaskRepetitionPattern

StartBoundary      : 2012-05-15T23:00:00

RandomDelay        : P0DT0H0M0S

PSComputerName     :

Unregistering Cluster Task

The Unregister-ClusteredScheduledTask allows you to remove tasks by invoking the cmdlet indicating the cluster and the name of the task to be removed.

Unregister-ClusteredScheduledTask –Cluster MyCluster –TaskName MyResourceSpecificTask


Task Scheduler (taskschd.msc) snap-in

While clustered scheduled tasks can only be managed through PowerShell, they also show up in the Task Scheduler UI under the Failover Clustering folder.

Frequently Asked Questions (FAQ):

If the resource for a ‘resource specific’ task is removed, what happens to my Task?

It can happen that the resource we selected for a ‘resource specific’ task gets removed from the cluster. In this case, the task will also be removed from the cluster.

Evicting a node. Will my tasks still be in the node?

No. As part of the process of evicting a node from the cluster, the tasks get deleted.

Can I change the type of my task after it’s registered?

No. A task that has been registered cannot be converted from any node, cluster wide, or resource specific.

Can I still create non-clustered tasks on a cluster node?

Yes. All the Cluster Tasks get created under path <PATH>. Thus, as long as your non-clustered tasks are under a different path you can always create them on individual cluster nodes. It is important  to note that as part of the process of evicting a node from the cluster, all the tasks under the <PATH> would get cleaned up.


In Windows Server 2012, Clustered Scheduled Tasks can be created quickly and easily – they can be used to maintain the cluster, cluster resources such as disks, and even applications that are running on the cluster.


Ramón Alcántara
Software Development Engineer in Test
Clustering & High-Availability

Leave a Comment
  • Please add 1 and 1 and type the answer here:
  • Post
  • Some days ago we rebootet the Cluster nodes, one by one and a few days later when the cleanup tasks are not running the disk was full I found out the Tasks are simply "disabled". This are a Resounse Specific tasks.

    How is this possible? We have not disabled these tasks and this is not the first time that this happens. I guess the task is not automatically enabled if the resource comes up. But I have no idea how to debug.

    The ps script is located on the resource. I can manually enable the task and it will run manually, too. This looks like a bug to me and I have no idea what enables a resource specific clustered task.

  • Is it possible to run or start a clustered scheduled task from powershell? If not How do you run the clustered scheduled task manually. I don't see a cmdlet for this.

    Thank you

  • Hi. Is there any way to use the PowerShell cmdlets to create a scheduled task that repeats monthly, but given a numbered week? In the Task Scheduler this is possible. You can set a task to repeat on the First, Second, Third, Fourth, Last week of the month. As far as I can see, this isn't possible with the built-in cmdlets.

  • Is there anyway to create a Clustered Scheduled Task that will automatically run when a resource fails over?

    e.g. On our File Server Fail Over cluster we have a script that monitors a folder on a clustered drive, it starts automatically in the morning from a clustered scheduled task and runs throughout the day.

    Is there anyway to create a trigger that starts the script on the new hosting node after the attached resource fails over?

    I have been looking at using an Event based action Microsoft-Windows-FailoverClustering ID#1201 to trigger it, but I can not see how to create an Event based trigger using only PowerShell. All the online guides are pretty much Right Click on Event in Event View and choose "Attach Task To This Event", but this will not work with a clustered scheduled task.

  • For anyone else interested I was able to create a Clustered task that triggered after the resource moved.

    I had to create and modify the task in GUI, add an Event Trigger for Microsoft-Windows-FailoverClustering ID#1201 and I also added a 1 min delay to give time for Drive to move.

    Then export as XML and import using

    $path = "C:\ClusterJob.xml"

    $xmlFile = Get-Content $path | Out-String

    Register-ClusteredScheduledTask -TaskName MyTask -Xml $xmlFile -Cluster MyCluster –TaskType ResourceSpecific -Resource "MyResourceDrive"

    One problem with this is it can not tell the difference between different resources moving. This is visible in XML details of event. Because of this make sure the Task is set to only allow one copy to run at once.


     <Data Name="ResourceGroup">MyResourceDrive</Data>


  • I'm going to re-ask Nico Clevers question.  When is MS going to publish a .NET API for  registering a clustered task?  Using powershell from within C# application for this very clumsy and potentially error prone.  We have a great deal invested in using the (very robust) task scheduler from within our own C# application and I don't see how doing tasks from powershell can be a valid long term solution.

Page 2 of 2 (21 items) 12