Comments on Create an idle trigger in Power­Shell for Windows Task Scheduler

Be civil and read the entire article first. This is not a support forum. Comments from new contributors are moderated. English only.

Leave a comment

Required. Optional. E.g. your homepage, Twitter. or Email required unless anonymous. Not published or shared. Reuse to be recognized as the same commenter.
Plain-text only. Begin lines with a > character to quote.

Thanks for posting this.

Like you, I found that I was unable to create a scheduled task using the format for times shown in some of the examples on https://learn.microsoft.com/en-us/powershell/module/scheduledtasks/new-scheduledtasksettingsset?view=windowsserver2022-ps

For example IdleDuration 00:05:00 -IdleWaitTimeout 01:00:00

HOWEVER, the problem is, the examples are WRONG.

When you look at the definition of New-ScheduledTaskSettingsSet inthe same page, it sayd clearly that IdleDuration and IdleWaitTimeout are of TYPE TimeSPAN!!

Therefore they are not specified as HH:MM:SS but as "New-TimeSpan".

For example:

-IdleDuration (New-TimeSpan -Minutes 5) -IdleWaitTimeout (New-TimeSpan -Hour 2)

If you use this approach you CAN create a scheduled task using Register-ScheduledTask and New-ScheduledTaskSettingsSet, with values specified for IdleDuration and IdleWaitTimeout