There will be times as a Windows Administrator that 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 Shutdown Command
Windows systems has a built in shutdown command that can be used to restart or shutdown local and remote computers.
Using command line options with mstsc.exe and creating desktop shortcuts to connect to particular servers is the next step that you need to make. You can find more information about Remote Desktop at the following links. Microsoft TechNet – Mstsc command line options; Microsoft: Remote Desktop Connection (Terminal Services Client 6.0). Enable Multimon using one of the three methods described below: a. Click “Use all monitors for the remote session” in the client (mstsc.exe) window. Use the “/multimon” switch on the mstsc.exe command line. Add “Use Multimon:i:1” to the RDP file. Connect to a computer running Windows 7 or Windows Server 2008 R2. By default on a Windows Server Product Windows Remote Management (WinRM) is enabled, but Remote Desktop (RDP) is Disabled. On workstation operating systems neither is enabled by default, so if you want to be able to accomplish the following you will need to enable WinRM on the workstations. Enabling RDP remotely. Method 1: Command Line. I'm trying to run the remote desktop from the command line. I used - mstsc /console /v:166.122.91.11, and I got into the remote, but asked for the password. Is there a way to pass the remote's password from the command line so I only have to run 1 command line? This thread is locked.
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
Microsoft Remote Desktop From Command Line
/c “comment” – Message to display on the screen before restart or shutdown
Windows Remote Desktop Command Line Username Password
Now lets move onto some examples
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.
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.
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.
If you want a longer countdown just specify the seconds /t 60
Example 4: Log user off remote computer
If you just want to log a user off the remote computer use this command.
Restart or Shutdown 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.
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.
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.
Example 4: Use PowerShell to shutdown down two computers
Have fun!
Used by thousands of Professionals to Simplify and Automate Active Directory Management.