Powershell - Set-ClusteredScheduledTask - Error "Incorrect function."

Posted by NealWalters on Server Fault See other posts from Server Fault or by NealWalters
Published on 2014-08-22T19:04:19Z Indexed on 2014/08/22 22:23 UTC
Read the original article Hit count: 717

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

Error:

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

Error:

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

© Server Fault or respective owner

Related posts about powershell

Related posts about scheduled-task