Monday, June 6, 2011

Remotely Rebooting Machines

I noticed there are some machines on the network that haven't been rebooted for quite some time. As time moves along, new gpo's are created, software is updated, etc. Nonetheless, every month or two, all machines should be rebooted to pick up what has changed.

Create a .cmd file with this command in it:
for /f "tokens=*" %%c in (machines.txt) do shutdown /r /f /m \\%%c
You also need to create a txt file in the same directory that includes the machines you want rebooted. Make sure you do not include \\ in front of the computer name. If you prefer leaving \\, then revise the command above.

/r - Indicates to reboot the machine
/f - Force running applications to close without forewarning users
/m - Specify the remote computer in \\

Run your .cmd file in the command prompt window so you can see which machines errored out. You may need to adjust your screen buffer size if you have alot of machines.
Note - There may be computers that are shutdown or in Sleep mode, this command will error out if it cannot contact the machine, however, it will proceed to the next machine after about 15 seconds. Keep a list of what computers errored out and visit them individually.
2E01: The entered computer name is not valid or remote shutdown is not supported on the target computer.
Also, if you dont have the proper permissions to do so, this will fail.

No comments:

Post a Comment