Register-ClusteredScheduledTask : The parameter is incorrect

5

While executing below Register-ClusteredScheduledTask i am getting this error.

Register-ClusteredScheduledTask -TaskName $ClusterTaskName -TaskType AnyNode -Xml $TaskXML | Out-Null

Register-ClusteredScheduledTask : The parameter is incorrect.

At C:\Setup-Scheduler.ps1:215 char:5
+     Register-ClusteredScheduledTask -TaskName $ClusterTaskName -TaskT ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo: InvalidArgument: (PS_ClusteredScheduledTask:Root/Microsoft/...ed
ScheduledTask) [Register-ClusteredScheduledTask], CimException
+ FullyQualifiedErrorId: HRESULT 0x80070057,Register-ClusteredScheduledTask

My XML

<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
  <RegistrationInfo />
  <Triggers>
            <TimeTrigger>
          <Repetition>
            <Interval>PT15M</Interval>
            <StopAtDurationEnd>false</StopAtDurationEnd>
          </Repetition>
          <StartBoundary>2016-11-08T13:26:00</StartBoundary>
          <Enabled>true</Enabled>
        </TimeTrigger>
        <TimeTrigger>
          <Repetition>
            <Interval>PT5H</Interval>
            <StopAtDurationEnd>false</StopAtDurationEnd>
          </Repetition>
          <StartBoundary>2016-11-09T19:29:00</StartBoundary>
          <Enabled>true</Enabled>
        </TimeTrigger>
        <CalendarTrigger>
          <StartBoundary>2016-11-09T19:29:00</StartBoundary>
          <Enabled>true</Enabled>
          <ScheduleByDay>
            <DaysInterval>1</DaysInterval>
          </ScheduleByDay>
        </CalendarTrigger>
        <CalendarTrigger>
          <StartBoundary>2016-11-09T00:00:00</StartBoundary>
          <Enabled>true</Enabled>
          <ScheduleByMonth>
            <DaysOfMonth>
              <Day>9</Day>
            </DaysOfMonth>
            <Months>
              <January />
              <February />
              <March />
              <April />
              <May />
              <June />
              <July />
              <August />
              <September />
              <October />
              <November />
              <December />
            </Months>
          </ScheduleByMonth>
        </CalendarTrigger>
        <CalendarTrigger>
          <StartBoundary>2016-11-09T00:00:00</StartBoundary>
          <Enabled>true</Enabled>
          <ScheduleByMonth>
            <DaysOfMonth>
              <Day>9</Day>
            </DaysOfMonth>
            <Months>
              <November />
            </Months>
          </ScheduleByMonth>
        </CalendarTrigger>

  </Triggers>
  <Settings>
    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
    <AllowHardTerminate>true</AllowHardTerminate>
    <StartWhenAvailable>false</StartWhenAvailable>
    <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
    <IdleSettings>
      <Duration>PT10M</Duration>
      <WaitTimeout>PT1H</WaitTimeout>
      <StopOnIdleEnd>true</StopOnIdleEnd>
      <RestartOnIdle>false</RestartOnIdle>
    </IdleSettings>
    <AllowStartOnDemand>true</AllowStartOnDemand>
    <Enabled>false</Enabled>
    <Hidden>false</Hidden>
    <RunOnlyIfIdle>false</RunOnlyIfIdle>
    <DisallowStartOnRemoteAppSession>false</DisallowStartOnRemoteAppSession>
    <UseUnifiedSchedulingEngine>true</UseUnifiedSchedulingEngine>
    <Volatile>true</Volatile>
    <WakeToRun>false</WakeToRun>
    <ExecutionTimeLimit>PT72H</ExecutionTimeLimit>
    <Priority>7</Priority>
  </Settings>
  <Actions>
    <Exec>
      <Command>C:\Schedulers\CrystalHR\ADMS Download Command\ADMSManualCommand.exe</Command>
      <WorkingDirectory>C:\Schedulers\CrystalHR\ADMS Download Command</WorkingDirectory>
    </Exec>
  </Actions>
</Task>

To verify where my XML is correct i used the same xml with below code

Register-ScheduledTask -TaskName "Dummy" -Xml $TaskXML -User "XX\YY" -Password "XXXXX" -Force | Out-Null

and it worked correctly. Then my XML should be correct.

I also tried registering the clustered scheduler task by directly using simple Trigger and Action and even that worked.

Register-ClusteredScheduledTask -TaskName $ClusterTaskName -TaskType AnyNode -Trigger $SingleTaskTrigger -Action $TaskAction | Out-Null

It looks like the my xml which works with standard scheduled task does not work with clustered scheduler task due to some invalid parameter which not documented for clustered task anywhere. Do anyone have a such documentation for the same?

Please help me out.

UPDATE

After running $Error[0] | fl -f got below error

writeErrorStream      : True
OriginInfo            :
Exception             : Microsoft.Management.Infrastructure.CimException: The
                        parameter is incorrect.

                           at Microsoft.Management.Infrastructure.Internal.Oper
                        ations.CimAsyncObserverProxyBase`1.ProcessNativeCallbac
                        k(OperationCallbackProcessingContext
                        callbackProcessingContext, T currentItem, Boolean
                        moreResults, MiResult operationResult, String
                        errorMessage, InstanceHandle errorDetailsHandle)
TargetObject          : PS_ClusteredScheduledTask
CategoryInfo          : InvalidArgument: (PS_ClusteredScheduledTask:Root/Micros
                        oft/...edScheduledTask)
                        [Register-ClusteredScheduledTask], CimException
FullyQualifiedErrorId : HRESULT 0x80070057,Register-ClusteredScheduledTask
ErrorDetails          :
InvocationInfo        : System.Management.Automation.InvocationInfo
ScriptStackTrace      :
PipelineIterationInfo : {0, 1, 0}
PSMessageDetails      :
powershell
scheduled-task
asked on Server Fault Nov 16, 2016 by Vivek Khandelwal • edited Nov 18, 2016 by Vivek Khandelwal

1 Answer

3

I was able to resolve this issue by choosing a different task name. I have seen this under two circumstances:

  1. I have a scheduled task that has become corrupt. Even deleting it won't free up the task name, it must be cached somewhere.
  2. I had an unsupported character in a task name e.g. /

Both can be resolved by choosing a new name. I've found it useful to try creating an empty task with the name you'd like, as the errors in the GUI are better than a simple CimException.

answered on Server Fault Sep 6, 2018 by austincrft

User contributions licensed under CC BY-SA 3.0