Powershell - Set-ClusteredScheduledTask - Error "Incorrect function."
- by NealWalters
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