A good way to reboot all computers on a Windows domain each night


Solution 1

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 {
        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.

Solution 2

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.

Solution 3

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).

Solution 4

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.


Related videos on Youtube

Author by


Updated on June 10, 2022


  • steampowered
    steampowered 10 days

    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)

  • Bart Silverstrim
    Bart Silverstrim over 10 years
    Additionally there is a psshutdown command that can run through a batch file as well, part of the sysinternals suite...
  • Richard West
    Richard West over 10 years
    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.
  • jscott
    jscott over 10 years
    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
    jscott over 10 years
    The -AsJob is the magic bit here.
  • steampowered
    steampowered over 10 years
    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?
  • TomTom
    TomTom over 10 years
    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.
  • steampowered
    steampowered over 10 years
    Well, doing my job properly means not spending too much time babying our little windows system.
  • TomTom
    TomTom over 10 years
    Not knowing what you do? ;) I fire people saying they are incompetent ni their job, regardless how their performance is.
  • steampowered
    steampowered over 10 years
    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.
  • MDMarra
    MDMarra over 10 years
    @TomTom This is not so rare in higher education where students leave computers on overnight in all kinda of different states. It also ensures that any software deployed via GPO is installed overnight as well, and not at the beginning of the first class of the day.
  • Multiverse IT
    Multiverse IT over 10 years
    I agree - you need to address the problems causing this, not reboot all the workstations. If this is beyond your skill then they should hire someone to professionally manage the network. If you're not a pro and you're just trying to go on the cheap then there are probably other issues you have that should be addressed. As for this not being in the spirit of offering a tech solution, I would say not all "best solutions" must be technical to the question asked. Many people would prefer to offer professional advice not just a blind solution.
  • MaCuban
    MaCuban almost 7 years
    I am unfamiliar with setting Scheduled tasks with GPO, so i am wondering: if a machine is moved from one OU to another without the task defined, will the Shed Task disappear or will it remain after it is applied the first time?
  • Charles Burge
    Charles Burge over 5 years
    I'm curious why you're using the "shutdown" command rather than the Restart-Computer cmdlet.
  • sysadmin1138
    sysadmin1138 over 5 years
    @CharlesBurge This was answered 5 years ago, and PS3 wasn't widely deployed. Also, this demonstrates the technique of running commands on other systems. In 2017, we'd just do it all in PowerShell and not bother with commands. Times change.