Stagger Scheduled Task Creation

C

CisnerosKevin68

I'm trying to create a powershell script that will create scheduled tasks to reboot a list of servers weekly. I was wondering if there was a way to change the script so that when the scheduled tasks are created, the time that is assigned as the trigger for each task is staggered, so that way the servers aren't all scheduled to reboot at the same time. This is what my script looks like so far,

$List=Get-Content 'c:\Temp\SvrList.txt'
Foreach ($server in $List)
{
Invoke-command -ComputerName $server -scriptblock {
$Sta = New-ScheduledTaskAction -Execute c:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Argument 'restart-Computer -force'
$Stt = New-ScheduledTaskTrigger -Weekly -DaysOfWeek Sunday -At 11am
Register-ScheduledTask SundayReboot -Action $Sta -Trigger $Stt -User SYSTEM -Force -RunLevel Highest}
}


I'd like it so that they're scheduled to reboot around 2 minutes after each other. I appreciate any help you can offer, thanks!

Continue reading...
 
Back
Top Bottom