Understanding -TaskType ClusterWide on ScheduledClusteredTasks

09/15/2014 14:46:28 Test
09/15/2014 14:47:02 Test
09/15/2014 14:48:02 Test
09/15/2014 14:49:02 Test

$Action1 = New-ScheduledTaskAction -Execute "I:\Scripts\TestClusteredTaskRS.cmd"
$Action2 = New-ScheduledTaskAction -Execute "E:\Scripts\TestClusteredTaskCW.cmd"
$DurationTimeSpan = New-TimeSpan -Minutes 1 
$DurationTimeSpanIndefinite  = ([TimeSpan]::MaxValue) 
$DurationTempTest = New-TimeSpan -Days 1000
$Trigger = New-ScheduledTaskTrigger -Once -At "00:01" -RepetitionInterval $DurationTimeSpan -RepetitionDuration $DurationTimeSpanIndefinite  

#Register-ScheduledTask -TaskName "RegularCalcTest2" -Action $action
#Register-ClusteredScheduledTask -TaskName "CalcTask01" -TaskType AnyNode -Action $Action1 -Trigger $Trigger -Cluster "YourClusterNameHere"
Register-ClusteredScheduledTask -TaskName "TestResourceSpecific" -TaskType ResourceSpecific  -Action $Action1 -Trigger $Trigger -Cluster "YourClusterNameHere" -Resource BizTalk2013
Register-ClusteredScheduledTask -TaskName "TestClusterWide"      -TaskType ClusterWide       -Action $Action2 -Trigger $Trigger -Cluster "YourClusterNameHere"

Contents of TestClusteredTaskCW.cmd
powershell -command "& 'E:\Scripts\TestClusteredTaskCW.ps1'"


$TraceFilename = "E:\scripts\TestClusterWide_Trace.txt"
$currentDateTime = Get-Date 
Add-Content $TraceFilename "$currentDateTime Test" 
Write-Host "Completed, see `$TraceFilename=$TraceFilename" 

ClusterName : YourClusterNameHere
CurrentOwner :
Resource : 6f04356c-2f34-306b-9afb-a64e9556942f
TaskDefinition : MSFT_ScheduledTask (TaskName = “TestResourceSpecific”, TaskPath)
TaskName : TestResourceSpecific
TaskType : ResourceSpecific
PSComputerName :

ClusterName : YourClusterNameHere
CurrentOwner :
Resource :
TaskDefinition : MSFT_ScheduledTask (TaskName = “TestClusterWide”, TaskPath)
TaskName : TestClusterWide
TaskType : ClusterWide
PSComputerName :

Write “==================”
Write “Expanded:”
foreach ($item in Get-ClusteredScheduledTask )
Write-Host $item.TaskName

TaskName TaskType
——– ——–
TestClusterWide ClusterWide
TestResourceS… ResourceSpecific


Related Posts:

1. http://stackoverflow.com/questions/16767064/clustered-scheduled-task

2. http://serverfault.com/questions/623407/powershell-set-clusteredscheduledtask-error-incorrect-function – error trying to Register-ClusteredScheduledTask

3. http://serverfault.com/questions/628958/how-to-enable-or-disable-a-clusteredscheduledtask-in-powershell-4-0 – how to you enable/disable a ClusteredScheduledTask?


I’m still cleaning up this blog post.  Here are some points to consider.


1. With ClusteredScheduledTasks there is no GUI.  When you do register a ClusteredScheduleTask using Powershell, it shows up in the GUI, but even then it is not reliable to use the GUI to change anything.   I tried changing few things, and they certainly did NOT sync between the two servers.

2. The problem with regular ScheduledTasks is that you have to maintain one TaskScheduler on each machine in the node.  Not too bad with two nodes, but if you have more it can be tedious.  Even with two nodes, everyone that is an admin has to be a stickler for keeping them in sync.
We thought about trying to write some code to keep them in sync, but looks like that could take several days.  In my opinion, you have the task, the triggers, and the actions all to keep in sync, and the triggers themselves have quite a few options.

At my client, we had two nodes, and decided to live with regular scheduled tasks for now.

3. You can always buy a third party tool.  Where I used to work, they had “VisualCron“.  I recently asked their sales person if they supported clustering, and rather than giving me a straight forward yes or no, and he sent me to a forum post which implies it can be done, but if it is so easy, there would be that much discussion about it.

4. We considered using SQL Agent as our task scheduler, but then we might have to change some of our code to work “cross-machine”, i.e. from the SQL machine over to the machine being monitored.  (Some of our schedule tasks kick of BizTalk jobs, and others are for monitoring EventLog, creation of extract files, MQ Depth, etc…)




Leave a Reply