I’m trying to put together a script that, is run by a scheduled task. I want the scheduled task to run every 5 minutes (I.E., if the user cancels it - it starts again 5 minutes later), until it successfully completes, in which case - it doesn’t run until the next day at 6:00am.
Here’s what I’ve done:
$trigger = New-ScheduledTaskTrigger -Weekly -daysOfWeek 1,2,3,4,5 -at 6:00am $Trigger.StartBoundary = "$(get-date (get-date).date -format "yyyy-MM-dd")T13:00:00Z" Set-ScheduledTask -TaskName "_SchTask_$Name" -Trigger $triggerCurious if anyone has dealt with something like this, and found a good work around? I hate having to fall back to cmd-style executables, but feel I'll have to.
At this point, the scheduled task is set to run at the correct start time
$st = get-ScheduledTask -TaskName “SchTask$name”
$st.triggers.repetition.Duration = “PT8H”
$st.triggers.repetition.Interval = “PT5M”
$st | Set-ScheduledTask
Now - the start time has been reset to immediately.