4

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      :
  • Do you have a corrupted scheduled task? powershell.org/forums/topic/register-scheduledtask This article writes about using set-clusteredscheduledtask rather than registering in case it is already registered. serverfault.com/questions/623407/… Hope this helps. Thanks, Tim. – Tim Haintz Nov 17 '16 at 10:44
  • I have already looked into that. I have check with Get-ClusteredScheduledTask and found no task and the cluster is also configured correctly since i am able to create simple task without xml. – Vivek Khandelwal Nov 17 '16 at 12:21
  • Could you please duplicate the error and then run the following code: $Error[0] | fl -f. That should provide more detailed info about what's going on. Please update your answer with the result. – Colyn1337 Nov 17 '16 at 14:25
  • From serverfault.com/questions/623919/… it says that -xml is expecting a string. Thanks, Tim. – Tim Haintz Nov 18 '16 at 10:49
  • Thank you for updating with the additional error details. The error is actually from the Task Scheduler and not from Powershell. This means Powershell validated your inputs and passed them to the scheduler which returned the error. You'll need to do additional troubleshooting to track down the cause. This can be from security settings, service hang ups, and even patch level. – Colyn1337 Nov 18 '16 at 16:47
0

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.

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.