Interesting Reboot Challenge

This topic contains 9 replies, has 4 voices, and was last updated by Profile photo of turbo mcp turbo mcp 2 years ago.

  • Author
    Posts
  • #20321
    Profile photo of Lery
    Lery
    Participant

    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.

  • #20335
    Profile photo of Ondrej Zilinec
    Ondrej Zilinec
    Participant

    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
        
    }
    
  • #20340
    Profile photo of Lery
    Lery
    Participant

    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?

  • #20358
    Profile photo of Lery
    Lery
    Participant

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

  • #20376
    Profile photo of Lery
    Lery
    Participant

    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?

  • #20377
    Profile photo of Simon Wåhlin
    Simon Wåhlin
    Participant

    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/

  • #20378
    Profile photo of Lery
    Lery
    Participant

    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.

  • #20380
    Profile photo of turbo mcp
    turbo mcp
    Participant

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

You must be logged in to reply to this topic.