Reputation: 4735
$Sta = New-ScheduledTaskAction -Execute "Cmd"
$Stset = New-ScheduledTaskSettingsSet -RunOnlyIfIdle -IdleDuration 00:02:00 -IdleWaitTimeout 02:30:00
Register-ScheduledTask Task01 -Action $Sta -Settings $Stset
(Get-ScheduledTask Task01).Settings.RunOnlyIfIdle
via https://technet.microsoft.com/en-us/library/jj649824(v=wps.630).aspx
The RunOnlyIfIdle
property isn’t actually set when registering (or updating an existing task with Set-ScheduledTask
). You can also confirm that the option doesn’t have the option set in the Task Scheduler UI.
Upvotes: 1
Views: 1200
Reputation: 4735
Before anyone else wastes a day on this, the RunOnlyIfIdle
argument is in fact ignored by the TaskScheudler Cmdlets in Windows 10. You’re not doing anything wrong, it’s just broken straight outta the chocolate factory.
Update: I wrote up an article on the problems with the Task Scheduler cmdlets and documented a work-around.
Upvotes: 3