Restart windows server remotely

using COMMAND Line

1. Login with a full administrative account to another computer.

2. Open a Command Prompt (CMD) window.

3. Type the following command:

Example 1: Restart a remote server

Shutdown /m \\servername /r 

Example 2: Restart a remote server immediately

Shutdown /r /m \\servername /t 0

If you want to delay the restart, specify the seconds: e.g. /t 60

Example 3: Restart the remote server with a custom message

Shutdown /m \\servername  /c «The server will restart for maintenance purpose»

Example 4: Log off a user on a remote server

shutdown /l /m \\servername

using POWERSHELL

1. Login with a full administrative account to another computer.

2. Open a Powershell window.

3. Type the following command:

Example 1: Use Powershell to restart a remote server immediately

Restart-Computer -ComputerName REMOTE_COMPUTER_NAME -Force

Example 2: Use PowerShell to shut down a remote server

Stop-Computer -ComputerName REMOTE_COMPUTER_NAME -Force

Example 3: Use PowerShell to restart a list of servers

Restart-computer (get-content c:\serverslist.txt)

Example 4: Use PowerShell to shutdown multiple remote servers

Stop-Computer -ComputerName «Servername01», «Servername02»

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.

Each Administrator has experienced at least one time that he can not access the server to restart it, except physically. This can be very frustrating, in this article, I will try to describe how to configure Windows Server 2008 R2 and Windwos Server 2012 for remote restart using the command prompt ( CMD ).

You can find various tutorials of this type on the Internet, but most of them are useless because it is not complete. This remote control option works on Windows Server 2008 and Windows Server 2012 OS. First, you need to go on the Control Panel – Network and Sharing Center, Change Advanced Sharing settingsTurn on file and printer sharing and Turn on network discovery.

Turn On Local File And Print Sharing

Control Panel – Turn On File And Printer Sharing

After that, you type regedit.exe in the run, and after the window opens, go to the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System path and create a NEWDWORD file named LocalAccountTokenFilterPolicy and assign it a value of 1 to look like in the picture below.

Local Account Token Filter Policy

Registry Editor – Local Account Token Filter Policy

Since we have done the registry part, it is necessary to define which user will be able to access this type of server control. We do this by defining roles in Group Policy Management. On the Security SettingsLocal PoliciesUser Rights Assignment, we need to edit Force shutdown from a remote system. On the Force shutdown tab from a remote system Properties we need to add a user or group that can access the server shutdown or restart remotely.

Group Policy Management Editor

Group Policy Management Editor – User Rights Assignment

If everything is set up properly, we can start testing. Started Command Prompt with Administrator privileges on a computer that is on the same network as the server and then type the following commands:

net use \\serverip\ipc$ /user:domain\usename password 

After typing the command, press Enter. If everything is OK, you will be seen a message
“The command complete successfully” after which, you can start using the shutdown option. Below you will find the most commonly used options and some examples how to use shutdown.

So for remotely shutting down another machine on your network, you would type into the command prompt the following commands:

shutdown /m \\computerip /r /f

This command will restart the computer and force all programs that are still running to close.

shutdown –m \\computerip –s –f –c “The computer will restart, please save all work.” –t 60

This command will shutdown the computer, force all programs that are running to close, show a message to the user and countdown 60 seconds before it shuts down.

Here are a couple of the most common command:

/s: Shuts down the computer

/r: Restarts the computer

/m \\computeripThe target remote computer to shut down

/f: Forces programs to close immediately

/t: Will wait a certain amount of time in seconds before shutting down or restarting

/c “comment”: This shutdown command option allows you to leave a comment describing the reason for the shutdown or restart.

As a system administrator, one of the essential skills you need to master is the ability to efficiently manage and troubleshoot servers. This includes knowing how to restart a Windows Server using command-line tools. This article delves into various methods and tricks to restart Windows Server using the command line, a crucial technique for quick and effective server management.

To reboot a Windows server using the command line, you can employ the /r switch with the shutdown command. This article provides various examples of how to use command line instructions to restart Windows systems.

  • Restart Computer: For restarting a local Windows system, use the following command:
    
    shutdown /r
    
    
  • Restart Forecefully: To restart the local system and force all running applications to close, include the /f switch:
    
    shutdown /r /f
    
    
  • Adding a Timer: Optionally, you can add a delay to the restart process. For instance, below command will restart the server after 60 seconds.
    
    shutdown /r /t 60
    
    
  • Restart Remote Computer: If you need to restart a remote system, include the system’s hostname with the /m switch:
    
    shutdown /r /f /m \\REMOTE-PC
    
    
  • Adding Comments: Additionally, you can add a comment to document the reason for the reboot using the /c switch. For instance, if you are restarting the system after installing software, the command would be:
    
    shutdown /r /f /m \\REMOTE-PC /c "Post Installing Software"
    
    

These commands offer a streamlined and efficient way to manage system restarts directly from the command line.

Using PowerShell

For those who prefer PowerShell, the process is similar but uses different commands:

  1. Open PowerShell: Search for it in the start menu or type powershell in the Run dialog.
  2. Restart-Computer Command: Use the command Restart-Computer. This straightforward command initiates an immediate restart of the server.
    
    Restart-Computer
    
    
  3. Adding Parameters: Similar to Command Prompt, you can add parameters like -Delay to set a timer for the restart.
    
    Restart-Computer -Delay 60
    
    
  4. Restart Remote Server: If you need to restart a server remotely, you can use the following command in PowerShell:
    
    Restart-Computer -ComputerName [ServerName] -Force
    
    

    Replace [ServerName] with the actual name of the server. The -Force parameter ensures that all running applications are closed immediately.

Conclusion

Mastering the command line for restarting Windows Server is a vital skill for any system administrator. It provides a quick, reliable, and scriptable method to manage servers, especially in complex or remote environments. By incorporating these tips and tricks into your routine, you can significantly streamline your server management tasks.

Remember, while the command line is a powerful tool, always proceed with caution and ensure you have backups and a recovery plan in place for unforeseen circumstances.

Remote Restart Windows Server 2008

You can remotely reboot your Windows server with the built-in Shutdown.exe utility. 

Topics For Remote Server Restart

  • Shutdown.exe Command – The Basics
  • Select Your ComputerName with -m
  • Shutdown Access is Denied. (5)
  • Windows Shutdown – Check the Additional Commands
  • Launch The GUI With Shutdown -i
  • Windows 7 Shutdown Commands

 ♦

Built-inShutdown.exe Command – The Basics

This shutdown utility is available at the command line in Windows Server 2008 and earlier operating systems going right back to XP.  Start by typing cmd; remember to ‘Run as Administrator’.  Once the DOS box launches your first real decision is do you want to reboot (-r), or shutdown (-s) that server in another part of the network?

Note 1: The default with -r is the local machine!  Thus introduce the -m switch if you want a remote restart.

Note 2: While your ‘victim’ is probably a Windows Server, you can launch the command from Windows 7 or earlier Microsoft clients.

Warning:  Despite what anyone tells you, nobody gets to be an expert with Shutdown without accidentally downing the local machine instead of the target computer.  To recover from this mistake pay close attention to the syntax of Shutdown’s abort switch -a.

Select Your ComputerName With -m

When you attempt to restart a remote Windows server always remember that the default computername is the local machine, therefore to access a remote server you need to append  -m ComputerName. 

The full command would be:
Shutdown -r -m \\BigServer  If the minus sign is unfamiliar, you could try
Shutdown /s /m \\BigServer, in this example, ‘BigServer’ is the hostname of the remote operating system.  None of these commands is case sensitive so sHUTDOWN -R -m \\bigserver would work just as well.

Note 1:  There is no space between the double backslash and the computername
\\  BigServer would not work.

Note 2:  If you substitute -s for -r that would mean shutdown.

  For testing -m on the local machine, try 127.0.0.1
For example, shutdown -r -m  \\127.0.0.1  Such a command is useful in batch files.  Alternatively, to reboot numerous computers try PowerShell’s command Restart-Computer.

Examples of Shutdown switches

shutdown -r -m \\YourSrv – Reboots a remote machine called ‘YourSrv’.

shutdown -s -m \\Laptop – Shuts down, or stops a remote machine called ‘Laptop’.

While you probably want to reboot a Windows server, Shutdown works on all modern Microsoft client operating systems.

Note 3: For once the sequence of switches is vital, hence shutdown -m -s \\Laptop does not work.

Guy Recommends:  A Free Trial of the Network Performance Monitor (NPM) v12

SolarWinds’ Network Performance Monitor will help you discover what’s happening on your network.  This utility will also guide you through troubleshooting; the dashboard will indicate whether the root cause is a broken link, faulty equipment or resource overload.

Perhaps the NPM’s best feature is the way it suggests solutions to network problems.  Its second best feature is the ability to monitor the health of individual VMware virtual machines.  If you are interested in troubleshooting, and creating network maps, then I recommend that you give this Network Performance Monitor a try.

Download your free trial of SolarWinds Network Performance Monitor.

Shutdown Access is Denied. (5)

This is often a permissions problem, or to be precise a lack of the user right to ‘Force shutdown from a remote system’.

One solution is to launch Secpol.msc and adjust the settings as follows:

  1. Local Polices
  2.    User Rights Assigments  (Scroll down)
  3.        Force shutdown from a remote system
  4.        Add the user who needs to remotely restart the server.

Trap :  You typed Secpol, and forgot the .msc extension thus: Secpol.msc.  See more on Secpol

Windows Shutdown – Check the Additional Commands

Here is addition information about the optional commands to remotely restart your Windows Server.

-a  Is for abort.  Naturally it only works during the time-out period. Of all the optional switches, this the one to test before you start restarting servers for real.  The syntax is deceptively simple:

Shutdown -a

Avoid overthink, you don’t need the -m switch or the machine’s name.

See more about Cancel Windows Shutdown

-t is for time.  Is 30 seconds too long or too short a time?   You can adjust with -t: 60 to display the dialog box for one minute.  The maximum time is 600 seconds!

-f is for force.  ‘Mr Nasty’, is coming – ready or not!  Shutdown -r -f as you may have guessed, restarts the machine, and closes any programs without warning.

-c is for a comment.  Would you like to put your stamp on the shutdown?  Let people know who is in charge, who is restarting their server?  -c «Guy is shutting you down»

-d p:4:1 reason.  Personally, I would avoid this switch, the syntax is tricky the numbers obscure, and it does nothing exciting.  That said the idea is sound, it enters a reason for the shutdown in the event log.  If you activate shutdown’s help, then you will get a whole list of major and minor reasons that you could employ with this switch.  For me, this switch is an option, an option that I do not take.

Note 1: The shutdown command line switches work equally well with a forward slash, for example, /d, /r or /a  
(instead of -d, -r or -a)

Note 2: Here is another example of Shutdown in action

Guy Recommends : SolarWinds’ Free VM Monitor

The best feature of this new this new version of SolarWinds VM Monitor is that it checks Windows Hyper-V.  Naturally, it still works with virtual machines on VMware ESX Servers.  VM Monitor is a clever desktop tool that not only tests that your server is online, but also displays the CPU and memory utilization for each node.

It’s easy to install and to configure this virtual machine monitor, all you need the host server’s IP address or hostname and the logon info. Give this virtual machine monitor a try – it’s free.

Download your free copy of SolarWinds VM Monitor.

Launch The GUI With Shutdown -i

You could just click on the Start orb and type: ‘Shutdown -i’.

Consider making a shortcut to shutdown.  The advantage is that you can include the -i  (/i) for interactive switch.  The benefit is that you have a GUI to control your remote server restarts. 

Just right-click the desktop,  New, Shortcut, type
Shutdown -i

A shortcut is born.  (See screenshot above right).

Full List of Windows Server Shutdown Commands

Usage: shutdown [/i | /l | /s | /r | /g | /a | /p | /h | /e] [/f]
[/m \\computer][/t xxx][/d [p|u:]xx:yy [/c «comment»]]

/i Display the graphical user interface (GUI). This must be the first option.
/l Log off. This cannot be used with /m or /d options.
/s Shutdown the computer.
/r Shutdown and restart the computer.
/g Shutdown and restart the computer. After the system is rebooted, restart any registered applications.
/a Abort a system shutdown. This can only be used during the time-out period.
/p Turn off the local computer with no time-out or warning. Can be used with /d and /f options.
/h Hibernate the local computer. Can be used with the /f option.
/e Document the reason for an unexpected shutdown of a computer.
/m \\computer Specify the target computer.
/t xxx Set the time-out period before shutdown to xxx seconds.
The valid range is 0-315360000 (10 years), with a default of 30. If the timeout period is greater than 0, the /f parameter is implied.
/c «comment» Comment on the reason for the restart or shutdown. Maximum of 512 characters allowed.
/f Force running applications to close without forewarning users. The /f parameter is implied when a value greater than 0 is specified for the /t parameter.
/d [p|u:]xx:yy Provide the reason for the restart or shutdown.
p indicates that the restart or shutdown is planned.
u indicates that the reason is user defined. If neither p nor u is specified the restart or shutdown is unplanned.
xx is the major reason number (positive integer less than 256).
yy is the minor reason number (positive integer less than 65536).

Restart-Computer PowerShell Cmdlet

As an alternative to the built-in Windows Server shutdown command try PowerShell.  It has a family of cmdlets such as Stop-Computer and Restart-Computer.  A likely scenario is that you wish to automate the reboot of a remote server.  With a tiny substitution to the cmdlet’s verb you could change the command so that it simply shuts down the computer.  See more about using PowerShell’s restart-Computer cmdlet.

»

Summary of Remote Restart Windows Server

It’s fun to learn the Remote Restart Windows Server, and one day they will save you a long walk when you want restart or stop a remote computer.  My advice is to perfect the -a (abort) switch, that way you won’t panic if you issue a command to shutdown the local computer instead of the network machine. 

For beginners, shutdown -i helps you to check the options in a GUI.

If you like this page then please share it with your friends


Microsoft Windows Server 2008 Topics:

• Server 2008 Home   • Overview   • What’s New?   • Server Manager   • Install

• Hyper-V   • Windows LDP.exe download   • Group Policy   • Remote restart Windows server

• Network Performance Monitor   • Windows Server 2012   • SP1 Review   • IPAM 3 Review

Понравилась статья? Поделить с друзьями:
0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии
  • Зависает firefox windows 10
  • Сканирование на smb windows 10
  • Не могу подключить блютуз наушники к ноутбуку windows 10
  • Windows server 2019 core iso
  • Как правильно начать установку windows 10