There will be times as a Windows Administrator when you will need to reboot or shutdown a remote computer or server.
In this tutorial, I’ll show you two easy methods for rebooting and shutting down remote computers.
The first method uses a built in Windows command and the second method uses PowerShell.
Check it out.
Windows Remote Shutdown Command
Windows systems have a built in shutdown command that can be used to restart or shutdown local and remote computers.
The command is shutdown.
To use this command just open the windows command prompt and type shutdown.
To view the full list of command options type shutdown /? in the CMD window.
There are several command line switches, below I list the most useful options.
/s – Shutdown the computer
/r – restart computer
/m \\computer – Specify the remote computer
/l – Log off
/t xxx – Set the time out period before shutdown to xxx seconds
/c “comment” – Message to display on the screen before restart or shutdown
Now let’s move on to some examples
Remote Desktop Connection Manager | Remote Session Tools
Download 14 day Free Trial
Restart or Shutdown Examples with Command Line
In these examples, I’ll be on PC1 and will initiate a remote restart or shutdown on PC2.
I’ll be using the /r switch in these examples, you can change them to /s to shutdown instead of restart.
Example 1: Restart Remote Computer
By default, this will prompt the remote computer and give it about a minute before it restarts.
shutdown /r /m \\pc2
The pop up below is what a Windows 10 system will display.
Example 2: Restart With a Custom Message
You may want to display a custom message to the logged on users, to do that just use the /c command.
shutdown /m \\pc2 /c "The IT department has initiated a remote restart on your computer"
Below is the pop up on the remote computer with the custom message.
Example 3: Immediate Restart no Countdown
If you want to immediately restart with no countdown or message use this command.
shutdown /r /m \\pc2 /t 0
If you want a longer countdown just specify the seconds /t 60
Example 4: Log user off the remote computer
If you just want to log a user off the remote computer use this command.
shutdown /l /m\\pc2
Restart or Shutdown the Computer with Powershell
Here are a few examples of how you can restart or shutdown computers with PowerShell.
The downside to PowerShell is it doesn’t have as many options as the shutdown command. There is no option to prompt users with a custom message or provide a countdown.
Example 1: Use Powershell to restart a computer
This command will immediately restart a remote computer. The -Force option will force a restart even if a user is logged on.
Restart-Computer -ComputerName REMOTE_COMPUTER_NAME -Force
Example 2: Use PowerShell to shutdown a computer
This command will shutdown a remote computer. Use the -Force to force a shutdown even if a user is logged on.
Stop-Computer -ComputerName REMOTE_COMPUTER_NAME -Force
Example 3: Use PowerShell to restart a list of computers
This is handy if you have several computers to restart. Just list all the computers you want in a text file and add that to the PowerShell command.
restart-computer (get-content c:\work\computers.txt)
Example 4: Use PowerShell to shutdown down two computers
Stop-Computer -ComputerName "Server01", "Server02"
Want an easy way to check windows server uptime and last boot date on all computers? Then check out the tool below.
The AD Pro Toolkit includes 13 tools to simplify Active Directory and computer management. Download a free trial and try it for yourself.
I hope you found this article useful. If you have questions or comments leave them below. You might also like to check out my guide on How to Remotely Log off Windows Users.
Hello:
My remote computer is not a domain member, and I’m not able to force a reboot. The account I’m attempting to pass is a administrator on the remote machine, here’s my commands, any help will be appreciated!
net use \\remote-ip\ipc$ /user:remote-ip\username password
psshutdown64 \\remote-ip -u username -p password -r -e p:2:3
or
shutdown.exe /r /f /t 01 /m \\remote-ip
psshutdown64 \\remote-ip -u username -p password
is really super-Command for Remote Shutdown. It really work for
1) Access is denied.(5)
2)Failed to connect to registry
………………………….
Errors.
Thanks Chris
Thanks for this. I turned this into a bat file. just type the computer name at the prompt and it’ll restart the remote computer instantly and take you back to enter the next PC name.
@echo off
goto :input
cls
:input
echo Enter Computer Name to be restarted:
echo[
set /p computer=
shutdown /r /m \\%computer% /t 0
goto input
Another option for doing this is to use an app called Off. https://www.bridgetech.io/Off.html
I blocked phones from connecting to the corporate network. It made the helpdesk so mad 🙂
Stop-Computer : The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
This typically means it is a permission issue or the firewall is blocking the request.
Very good page, love it.
You can reboot the remote computer in the following way, with credentials from powershell:
Restart-Computer -ComputerName -Force –user
Ex:
Restart-Computer -ComputerName tests -Force –user
(it will ask you to enter the administrator credentials of the team in question)
This isn’t working. I keep getting Error 67. Help?
GRACIAS POR SU TIEMPO
de nada
smb is a file sharing protocol on windows server or PC.
For connecting any window server or PC, type \\server_name in windows explorer.
If file sharing is on and folders are shared, you will be promopted for user name and password
It says “access denied” although I am an administrator on the local and remote machine and I started my local cmd as administrator.
There are also policies to prevent remote shutdown and restart, your org could have those applied. You could have also launched cmd with the local pc’s admin account and not a domain admin account.
i have the same problem still trying to solve it
you need to connect to smb first \\server_name and then login with admin credentials
“you need to connect to smb first \\server_name”. I did not understand. Can you explain.
THANK YOU SO MUCH !!!! IT WORKS PERFECTLY …
GENIUS! That did it!!
I don’t think so we can use /l with /m…please verify
Per:
Shutdown /?
/l Log off. This cannot be used with /m or /d options.
Thanks
Hello can you help me with acces denied error at “/r /m \\pc2 /t 0” command
Did you try it with PSShutdown instead?
Can I use this for a PC I know the external IP address for? Im having trouble connecting to a PC on a site in UK (I’m in Cyprus) via UltraVNC, it appears to have not disconnected properly last time I was connected and I need to get the PC rebooted so I can update my software on it?
This traffic would most likely be blocked by a firewall but it can be done.
If i performed a shutdown on a target server using the /m command with /s, can i do the same afterwards with the /r command to restart it when it has already shut down? Would this work?
No the commands only work for shutting down and restarting a computer that is powered on. To turn on a computer that is shutdown it will need to be configured for Wake on LAN.