![Register-ClusteredScheduledTask : 参数不正确](https://linux22.com/image/693648/Register-ClusteredScheduledTask%20%3A%20%E5%8F%82%E6%95%B0%E4%B8%8D%E6%AD%A3%E7%A1%AE.png)
在下面执行 Register-ClusteredScheduledTask 时我收到此错误。
注册ClusteredScheduledTask-任务名称$ClusterTaskName-任务类型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
我的 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>
为了验证我的 XML 是否正确,我使用了与以下代码相同的 xml
Register-ScheduledTask-TaskName“Dummy”-Xml $TaskXML-用户“XX \ YY”-密码“XXXXX”-Force | Out-Null
并且它工作正常。那么我的 XML 应该是正确的。
我还尝试直接使用简单的触发器和操作来注册集群调度程序任务,而且这种方法还有效。
注册-ClusteredScheduledTask -任务名称 $ClusterTaskName -任务类型 AnyNode -触发器 $SingleTaskTrigger -操作 $TaskAction | Out-Null
看起来,适用于标准计划任务的 my xml 不适用于集群调度程序任务,因为某些无效参数在任何地方都没有记录集群任务。有人有这样的文档吗?
请帮帮我。
更新
运行后$Error[0] | fl -f
出现如下错误
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 :
答案1
我可以通过选择不同的任务名称来解决此问题。我在两种情况下都遇到过这种情况:
- 我有一个计划任务已损坏。即使删除它也无法释放任务名称,它一定缓存在某个地方。
- 我的任务名称中有一个不受支持的字符,例如
/
这两种情况都可以通过选择新名称来解决。我发现尝试创建一个带有您喜欢的名称的空任务很有用,因为 GUI 中的错误比简单的要好CimException
。