I’m attempting to create a scheduled task via PowerShell, but I’m running into a problem building the SettingsSet.
In the Task Scheduled MMC console the parameter in question is under Settings: “Stop the task if it runs longer than:”.
As part of trying to figure this out I have done the following:
Created a task with the checkbox unchecked for the setting
Exported the task to an .xml file
The value is PT0S (ISO 8601 timespan for 0:00:00).
When I check the checkbox to enable the setting and leave the default duration for 3 days and check the setting is PT72H as I would expect.
Knowing this in my code I set the ExecutionTimeLimit to 0:00:00; however, when the task is created the timespan is set to PT72H!!
If I set the ETL to 0:01:00 it is set to PT1M.
If I try to use [timespan]::MaxValue it throws an error
Register-ScheduledTask : The task XML contains a value which is incorrectly formatted or out of range.
(44,48):ExecutionTimeLimit:P99999999DT23H59M59S
Is it possible to create a task without an execution time limit? If so, what am I missing?
I ran into the same problem today when I wanted to create a scheduled task using PowerShell.
The [TimeSpan]::MaxValue have worked before, but not on this server (Windows Server 2016). Works fine on my workstation (Windows 10).
The repetition duration max value in my case is [timeSpan] “24855.03:14:07”
Second:
I’m running into this problem on Windows Server 2012 R2 as well. Has anyone else seen this behavior on other versions?
If it is a bug, is there any way to see if it is a known one?