I'm experimenting with Powershell to add a ClusteredScheduledTask on a clustered server (Win 2012/R2)
Technet sample code gives error:
#canned exampled from http://technet.microsoft.com/en-us/library/jj649815.aspx $Action01 = New-ScheduledTaskAction -Execute Notepad $Action02 = New-ScheduledTaskAction -Execute Calc Set-ClusteredScheduledTask -TaskName "Task03" -Action $Action01,$Action02
Set-ClusteredScheduledTask : Incorrect function. At I:\Scripts\TaskSchedulerSetupJobs\TestWebSampleCode.ps1:4 char:1 + Set-ClusteredScheduledTask -TaskName "Task03" -Action $Action01,$Action02 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (PS_ClusteredScheduledTask:Root/Microsoft/...edScheduledTask) [Set-ClusteredScheduledTask], CimException + FullyQualifiedErrorId : HRESULT 0x80070001,Set-ClusteredScheduledTask
Added: As KrisFR pointed out below, I really meant to do a Register, not Set, but I still get the same basic error:
#canned exampled from http://technet.microsoft.com/en-us/library/jj649815.aspx cls $Trigger = New-ScheduledTaskTrigger -At 12:00 -Once $Action01 = New-ScheduledTaskAction -Execute Notepad Register-ClusteredScheduledTask -TaskName "Task03" -Trigger $Trigger -Action $Action01
Register-ClusteredScheduledTask : The parameter is incorrect. At I:\Scripts\TaskSchedulerSetupJobs\TestWebSampleCode.ps1:5 char:1 + Register-ClusteredScheduledTask -TaskName "Task03" -Trigger $Trigger -Action $Ac ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (PS_ClusteredScheduledTask:Root/Microsoft/...edScheduledTask) [Register-ClusteredScheduledTask], CimExce ption + FullyQualifiedErrorId : HRESULT 0x80070057,Register-ClusteredScheduledTask
Update #2: From answers and comments below we have established:
1) adding -TaskType anynode changes error from "Incorrect parameter" to "Incorrect function" when running under PowerGUI, and
2) when I open ISE 32 bit or 64 bit with "Run as Administrator" - I get "Incorrect function"
3) when I open ISE 32 bit or 64 bit without "Run as Administrator" - I get
4) At some point earlier today, I was getting "Access denied" and/or "Permission Denied", I think that is when I was opening PowerGUI without "Run as Admin".
Are you trying to update an already registered cluster task or to register a new cluster task ?
From MSDN Blog :
Set-ClusteredScheduledTask : Update an already registered cluster task.
Register-ClusteredScheduledTask : Register a cluster task.
I guess you are looking for Register-ClusteredScheduledTask.
You need to add the -TaskType parameter and run it as admin:
$trigger = New-ScheduledTaskTrigger -at 12:00 -Once $action = New-ScheduledTaskAction -Execute "notepad" Register-ClusteredScheduledTask -Action $action -TaskName "clusteredtasktest" -Trigger $trigger -TaskType anynode
We worked with Microsoft to resolve this. Our problem was that the Admin had defined "Task Scheduler" as part of the "BizTalk2013" cluster node (OwnerGroup as seen on get-ClusterResource cmdlet). We deleted that ClusterResource. In our case "BizTalk2013" was our "OwnerGroup", which apparently needs to be "Task Scheduler".
It turns out that if our admin had not done anything, then running the Register-ClusteredScheduledTask cmdlet would have worked, and added "Task Scheduler" under a node called "Task Scheduler". I'm trying to find the blog that he followed in setting it up the way he did.
User contributions licensed under CC BY-SA 3.0