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
$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 
    + 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".

  • An incorrect function would be different from an incorrect parameter... – Davidw Aug 22 '14 at 21:30
  • Right. I guess I have no idea how to read these errors. Is there something that tells me which parameter? I'm not sure what "CategoryInfo" is. – NealWalters Aug 22 '14 at 22:28
  • I believe the CategoryInfo would be useful if you had a try catch block, where you could specify what to do if it hit that category of error. – Davidw Aug 22 '14 at 22:44
  • Try quotes around the name of the action you are executing for New-ScheduledTaskAction, per the example: technet.microsoft.com/en-us/library/jj649817.aspx – Davidw Aug 22 '14 at 22:49
  • You may want to double check what's in the variables by running the commands that create the variables, then calling the variable itself in the shell. – Davidw Aug 23 '14 at 0:34

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.

| improve this answer | |
  • You right on, I was using the wrong commandlet. However, I get exact same error on the the Register. For now, I will amend question. – NealWalters Aug 22 '14 at 20:58
  • So why didn't it say "Task not found", if I tried to set a task that didn't exist. Why does that make it an 'incorrect function'? Which function is incorrect? – NealWalters Aug 22 '14 at 22:29
  • I am not a Microsoft developper. Microsoft error messages are quite well known to be irrelevant. I am investigating on your problem – krisFR Aug 22 '14 at 22:30
  • Any idea on the Update, still getting "Incorrect function" after making your change. – NealWalters Aug 28 '14 at 15:29

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

The clustered scheduled task is running

| improve this answer | |
  • That still gives me "Incorrect function". I copied/pasted exactly what you posted. – NealWalters Aug 25 '14 at 16:41
  • Ok, now that's odd, I'll have to take another look at it this afternoon at the soonest. I had no errors, myself. – Davidw Aug 25 '14 at 16:58
  • 1
    Okay, I isolated one thing. I was running under PowerGUI when I got "Incorrect function". Under ISE, both 86/64 I get Access Denied even though I am administrator. – NealWalters Aug 25 '14 at 18:24
  • 1
    See update#2 to original question, got around Access Denied by doing "Run as Admin". – NealWalters Aug 25 '14 at 20:11
  • Did you actually run above code on a cluster, or is it a theoretical answer? Even though our cluster and failover for BizTalk and Windows is working fine, I'm wondering if something is defined wrong in clustering that causes the "Incorrect Function" for us in Powershell. – NealWalters Aug 28 '14 at 15:30

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.