Author Posts

November 4, 2014 at 3:02 pm

I'm presented with an interesting reboot challenge. I've a list of machines that I need to reboot. I can only reboot the machines in a two hour window in the early morning hours when I'm soundly asleep. So far this seems like a simple task. The complicated part? Reboot the machines in chunks of maybe 10,20, or 30. I cannot reboot them all at once.

I'm thinking about getting content and storing that in a variable. I can feed that to a for each and restart computer. The timing, early morning, throws me and so does the chunks of machines.

Your thoughts are greatly appreciated.

November 5, 2014 at 2:06 am

If you want just a simple script you can use very simple one:

$ComputerList = "Comp1", "Comp2", "Comp3"

Foreach ($Comp in $ComputerList)
{
    Restart-Computer -ComputerName $Comp
    
}

November 5, 2014 at 6:03 am

Thanks Ondrej. The challenge is to not reboot them all at once or immediately following each other. I'm wondering if putting in a pause for two minutes between each computer would do the trick?

November 5, 2014 at 6:09 am

Yes, you can use Start-Sleep.

November 5, 2014 at 9:09 am

Ondrej, simple enough. Thank you for the valued input.

November 5, 2014 at 10:49 am

You are welcome 😉

November 5, 2014 at 3:18 pm

I just realized that I did not solve the timing problem. I guess I can just remotely create a windows scheduled task to time it. Not sure that is the best approach?

November 5, 2014 at 3:24 pm

You can use a while-loop to wait until it is time.

I wrote a short blog post on this a while back: http://blog.simonw.se/powershell-tip-wait-for-a-certain-time/

November 5, 2014 at 3:34 pm

You can use a while-loop to wait until it is time.

I wrote a short blog post on this a while back: http://blog.simonw.se/powershell-tip-wait-for-a-certain-time/

That looks interesting. The for each can go right into the do part.

November 5, 2014 at 3:59 pm

you can also select only few computers at a time...
reboot sleep ping/test
continue