Windows 10 任务计划程序错误“XML 包含格式不正确的值”

Fre*_*red 5 windows-task-scheduler windows-10

自 Windows 10 升级以来,任何编辑先前存在的任务的尝试都会导致弹出错误窗口,指出:

任务 < 任务名称 > 发生错误
报告了以下错误:任务 XML 包含格式不正确或超出范围的值。

我找到了一个解决方法。如果我转到“常规”->“更改用户或组...”并重新输入当前用户,则编辑将被接受。在 Windows 8 下创建的旧任务和新任务(成功创建后)的行为方式相同:任何编辑后都必须重新输入用户名。

小智 3

如果您收到此错误,则很可能您
([timeSpan]::maxvalue)
的命令之一中有此错误。

例子:
New-ScheduledTaskTrigger -Once -At (Get-Date).Date -RepetitionInterval (New-TimeSpan -Minutes 35) -RepetitionDuration ([timeSpan]::maxvalue)

解决方法是将语句设置为遥远的未来某个特定时间。
$TheDate= ([DateTime]::Now) $Duration = $TheDate.AddYears(25) -$TheDate
New-ScheduledTaskTrigger -Once -At (Get-Date).Date -RepetitionInterval (New-TimeSpan -Minutes 35) -RepetitionDuration $Duration

感谢blog.netnerds