At some point most of us will run into the need to restart or shutdown a remote computer or server that we don’t have console access to.
While many RMM (remote management and monitoring) tools have this functionality coded in, not all of us are fortunate enough to work somewhere with these tools deployed.
Fortunately, Windows has various ways to shutdown and restart remote computers natively.
They are simple to use as well.
How to Use Native Windows Shutdown Command
Microsoft Windows 10 (and older versions) ships with a command prompt command set for shutting down or resetting remote (and local) workstations.
The command is quite literally:
Of course, there are various switches you’ll want to use in conjunction with this command to control the behavior. For a full list of commands, you can type:
Which will output several options including the following most commonly used options:
/i Display the graphical user interface (GUI). This must be the first option.
/m \\computer Specify the target computer.
/c Print comment to screen of computer before rebooting or shutting down.
/l Log off. This cannot be used with /m.
/s Shutdown the computer.
/sg Shutdown the computer. On the next boot, restart any registered applications.
/r Full shutdown and restart (reboot) the computer.
/g Full shutdown and restart (reboot) the computer. After the system is rebooted, restart any registered applications.
/a Abort (cancel) a system shutdown.
/p Turn off the computer with no time-out or warning.
/h Hibernate the computer.
/fw Combine with a shutdown option to cause the next boot to go to the firmware user interface.
/e Document the reason for an unexpected shutdown of a computer.
/t xxx Set the time-out period before shutdown to xxx seconds.
/f Force running applications to close without forewarning users.
The most common switches to use are the /r (to reboot) or /s (to shutdown).
I want to point out that you’ll need the Remote Registry service enabled and started on the remote computer and the Windows Management Instrumentation (WMI) firewall rule enabled on the remote computer for this to work. You’ll also need to ensure your user account has administrator permissions on the remote computer or the command will fail.
Let’s see it in action.
Shutdown or Restart Remote Computer Command Line Examples
Let’s get on COMPUTERA and attempt to restart and shutdown COMPUTERB using the command line in an elevated command prompt (run as admin).
Restart Remote Computer
shutdown /r /m \\COMPUTERB
Restart Remote Computer with Message
shutdown /r /m \\COMPUTERB /c “Your computer is about to restart”
Restart Remote Computer without Delay
shutdown /r /m \\COMUTERB /t 0
Alternatively you can specify a number higher than 0 to delay the shutdown command by that many seconds.
Shutdown Remote Computer
shutdown /s /m \\COMPUTERB
Shutdown Remote Computer without Prompt or Delay
shutdown /s /m \\COMPUTERB /p
Shutdown Remote Computer using a GUI
Entering the following command will open a GUI window that allows you to setup a restart or shutdown visually:
There is also another command line way of using the shutdown command and that is to use it in conjunction with PSEXEC from PsTools from Windows Sysinternals. You would simply use PSEXEC to connect the remote computer’s command line and then enter the commands as if you were at the console of the machine.
Shutdown Remote Computer using PSEXEC
psexec \\COMPUTERB cmd
Shutdown or Reboot Remote Computer with PowerShell
If you prefer to use PowerShell for most of your Windows admin tasks you’ll be glad to know you can restart and shutdown remote computers using PowerShell as well.
The only gotcha is that the PowerShell command set for restarting and rebooting is limited. There aren’t any switches for things like message prompts or countdowns. You can see all the options available by running the commands:
Restart Remote Computer with PowerShell
Restart-Computer -ComputerName COMPUTERB -Force
Shutdown Remote Computer with PowerShell
Stop-Computer -ComputerName COMPUTERB -Force
Restart Multiple Remote Computers with PowerShell
If you have a list of machines you need rebooted you can pipe them into the command using a text file like so:
Restart-Computer (get-content D:\Temp\Computers.txt)
Where D:\Temp\Computers.txt is the location of your text file with a single column of computer names.
There you have it, a few options for shutting down or restarting remote (and local) computers. Hopefully it saves you some time and aggravation!
Recommended for You: Solarwinds Server & Application Monitor (SAM)Know which applications are having issues in your environment before users complain? Know which systems are causing those problems? How about which servers are about to have problems like running out of space or memory?
Automate collection of data and alerting on your applications and servers with Solarwinds Server & Application Monitor so you have these answers.
Get insight into Active Directory, DNS, DHCP, and your Virtual and Applications environments without needing to mess with complex templates or knowing a single line of code.