Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

What is a good way to reboot a list of windows computers on a windows domain? Assuming the windows domain controller does not have a service to do this, please make recomendations for a script.

Can I list the host names and iterate though the host names to send a restart command to each? Can I get a list of host names from the DHCP server running in a Windows 2008 box at the script's runtime?

My preferred scripting languages from most to least desirable are: PHP, javascript, Bash, Python (know very little), VB (know it but don't like it)

share|improve this question
6  
flip the breaker. I kid. –  gravyface Oct 21 '11 at 0:54
    
that would cause a shutdown, I need a reboot. –  steampowered Oct 21 '11 at 3:38
    
@JM - not if they're set to "Resume previous power-state" in the BIOS. –  Fake Name Oct 21 '11 at 5:53
    
@Fake Name - that sounds like a lot of work –  steampowered Oct 21 '11 at 6:26

4 Answers 4

If GPO isn't your thing, and you want to go with Mark Henderson's second option (batching shutdown /m) you can make your job easier by batch-jobbing the shutdown so it'll do them in parallel rather than serial. It requires PowerShell on the part of the admin station, but it's very nifty.

foreach ($ComputerName in $ComputerList) {
    invoke-command -AsJob -ScriptBlock {
        params($ComputerName)
        shutdown /m $ComputerName /r /f /t 0
    } -ArgumentList $ComputerName
}

What this fragment does is spawn as many background jobs executing in parallel as there are machines in $ComputerList. This can make shutting All The Things down happen a lot faster.

share|improve this answer
1  
This is an interesting solution -- if you have alot of computers to reboot I would highly recomend this solution since it will run the shutdown commands in parallel. –  Richard West Oct 21 '11 at 1:55
    
The -AsJob is the magic bit here. –  jscott Oct 21 '11 at 2:09

Two options:

  1. Create a scheduled task via GPO that runs shutdown /r /f /t 0 or shutdown /g /f /t 0 on each machine you want to reboot. (check out shutdown /? for more detail.

  2. Create a batch that runs shutdown /m [computer name] /r /f /t 0 from a central computer (perhaps the domain controller?). Loop it for each computer you want to reboot (change the [computer name]). This means that the computer will not be restarted if it is unreachable for whatever reason, and needs to be run from an account that has the rights to restart computers.

You should be able to write a batch file that loops through a list of computers pulled from the active directory and runs the command, however I don't have the time to write one today (and I'm not willing to test it even if I did write it, otherwise I would be grilled out for rebooting everyones computer in the middle of the day).

share|improve this answer
    
Additionally there is a psshutdown command that can run through a batch file as well, part of the sysinternals suite... –  Bart Silverstrim Oct 21 '11 at 1:28
    
I've used both 1 and 2. Now having fun with Powershell. If using #2, consider the main script spawning separate process for each computer (e.g. start cmd /c shutdown /m computer /r /f /t 0) or using some logic to check if online, else the delay for offline computers can be significant. –  jscott Oct 21 '11 at 2:08

You can do this with Group Policy Preferences by making a new scheduled task that will run every night at a certain time. The command for that task should be shutdown /r /t 0. You can then link that GPO to the OU or OUs that have your computers in them.

You will probably want to use the "Run This Program At a Random Interval" option set somewhere between 10-15 minutes. Having every single computer power up at the same time can be bad for your breakers if you're not careful. You might also want to check the option to only run the task if the computer has been idle for x hours, in case someone is pulling an all-nighter. You don't want to kill a whole night's worth of work by rebooting someone that's trying to make a deadline.

share|improve this answer

The best way to do that is to fire the person having the idea that this is needed and the doing what all other people do - not do that.

share|improve this answer
    
The folder redirection seems to be tying up resources when people stay logged in overnight. I suppose I could try to set up a mass logout instead of a mass reboot, but rebooting seems to clear up so many problems. People go weeks or months without rebooting. I usually don't invest lots of time to learn the right way to run windows systems because it's not my primary job. What do you recommend? –  steampowered Oct 21 '11 at 5:30
1  
Ah - no. Tons of companies do not require their people to reboiot - you think they neve use folder redirection? I suggest fixing the issue at hand. I personally would be pissed if I would be logged out of my workstation every day - I often let jobs run overnight. Your laziness may cost lot of people hardship - do your job properly or hire someone who does. –  TomTom Oct 21 '11 at 5:42
    
Well, doing my job properly means not spending too much time babying our little windows system. –  steampowered Oct 21 '11 at 6:28
    
Not knowing what you do? ;) I fire people saying they are incompetent ni their job, regardless how their performance is. –  TomTom Oct 21 '11 at 11:16
    
Sysadmin is a side job I do for my family to help them out. If I had infinite time sure, I would read more books on windows and other tangents. But my best way to make money is to stick to web software. I think you answer was not at all in the spirit of offering a technical solution to the question I asked. –  steampowered Oct 21 '11 at 12:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.