How to restart or shutddown remote computer with CMD or PowerShell

How to restart or shutddown remote computer with CMD or PowerShell

What is a Remote Computer?

A remote computer is one that cannot be accessed physically. However, it can be accessed through a network link from another computer. This makes it easier for users and administrators to manage and access multiple computers for various purposes. This allows users to access files on a computer that is present at a remote location.

How to Restart or Shutdown a Remote Computer?

A system administrator may have several reasons to restart or shutdown remote computers. Rebooting or shutting down multiple computers manually is a tedious task. They can simplify the process of restarting or shutting down multiple remote computers using the following methods.

Enabling Remote Registry Services

The Remote Registry service has to be enabled in order to allow for the restart or shutdown of remote computers. Since this is disabled by default, it can be enabled using these steps: 
On the computer that you want to restart remotely, open the Start menu and select the Services application.
If the option is not available, type services.msc in the Run window to open the application.
From the list of available services, locate the Remote Registry option.
Right click on Remote Registry and select the Properties option.
The Remote Registry Properties dialog box appears.
In the General tab, locate the Startup type field and set it to Automatic.
Click on Start and then OK to save the settings and enable the remote registry service.
Open the Windows Firewall from the Start menu.
In the Windows Firewall control panel, select “'Allow an app or feature through Windows Firewall' from the menu on the left.
Click on Change Settings.
Enable the Windows Management Instrumentation (WMI) option from the list and click OK.
This ensures that remote access to the computer is not blocked by the firewall.
Editing the Registry
This step is followed while the target computer is running on Windows Vista, Windows 7 or Windows 8. This is used to edit the registry which can be done by following the steps given below.
Open the Start menu and search for 'regedit' to open the Registry Editor.
Navigate to the registry key given as follows:
Computer\HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System
Right click on the System folder which is present on the left side of the window.
Select Newà DWORD (32-bit) Value.
In the Edit DWORD dialog box, enter the Value name as LocalAccountTokenFilterPolicy.
Double click on the value and change it from 0 to 1.
Click Ok and close the registry.     

Using Command Prompt

Once the Remote Registry Services have been enabled on all the computers that are to be accessed remotely, the administrator can restart or reboot a remote computer using the command prompt. This can be done by following the steps given below.
Open the Start menu by clicking on the Start button.
Type cmd to open Command Prompt.
Right click Command Prompt and select Run as Administrator. This can be done only from an administrator account.
In the Command Prompt, type shutdown/?
There are multiple command line switches that are available. These are listed as follows.
/i – Display the graphical user interface (GUI).
/l – Log off. This cannot be used with the /m or /d options.
/s – Shutdown the computer.
/r – Shutdown and restart the computer.
/g – Shutdown and restart the computer. After the computer is rebooted, restart any registered applications
/a – Abort a system shutdown. This can be used only during the time-out period.
/p -- Turn off the local computer without a time-out or warning. This can be used with the /d or /f options.
/h – Hibernate the local computer. This can be used with the /f option.
/e – Document the reason for an unexpected shutdown.
/m \\computer name – Specify the target computer
/t xxx – Set the time-out period before shutdown to xxx seconds.
/f – Force programs to close immediately.       
            
Choose the required option by typing in the specified command.
To restart a specific remote computer, type shutdown /r /m \\computername
Similarly, to shutdown a remote computer, type shutdown /s /m \\computername
In the same manner, the various options can be used to perform specific operations from the list that is provided.

Using the Shutdown Dialog Box

The process of rebooting or shutting down a remote computer can be simplified by using the Shutdown Dialog Box. This reduces the hassle of typing in commands and switches and provides a GUI for performing the same operations. This can be done by following the steps mentioned below.
In the Command Prompt type shutdown /i
The Remote Shutdown Dialog Box appears.
To add the required computers to the list, click on the Add or Browse buttons.
Enter the names of the target computers, in case you choose the Add option.
Click OK and choose the option to either restart or shutdown the computer.
Likewise, specify the other options such as “Warn users of the action”, “Display warning for [ ] seconds”, “Reason for shutdown” and “Comment”.
After selecting the required options, click OK to complete the process.

Using PowerShell

Administrators can restart or shutdown remote computers using PowerShell commands. These are listed as follows.
To restart a remote computer, use the following command.
Restart-Computer -ComputerName -Force
 
To restart multiple remote computers, use the following command.
Restart-Computer -ComputerName Server01, Server02, localhost
 
To shutdown a remote computer, use the following command.
Stop-Computer –ComputerName –Force
 
To shutdown multiple remote computers, use the following command.
Stop-Computer -ComputerName Server01, Server02, localhost
    • Related Articles

    • How to Update GPOs on Remote Computers

      Updating GPOs On Remote Computers Group Policy Objects can be added or modified by the administrator according to the requirements of the organization. Generally, the time taken for a new Group Policy Object (GPO) to be applied is between 90 and 120 ...
    • PowerShell Remoting: Accessing Remote Computers with Precision

      In today's interconnected IT environments, managing remote computers is an essential task for system administrators. PowerShell Remoting, a powerful feature of Windows PowerShell, allows administrators to access and control remote machines ...
    • How to block remote network access for local user accounts in Windows

      Introduction Local user accounts accessing other computers in the Active Directory (AD) network remotely may cause huge problems due to the security risk associated with the access privilege. The most commonly cited example is that if multiple user ...
    • How to list all computer accounts in the domain using Powershell

      Active Directory is the backbone of many organizations, and managing computer accounts within it is a critical administrative task. PowerShell, with its flexibility and robust capabilities, offers a powerful way to list all computer accounts in a ...
    • How to Populate Computer Model Information on Active Directory

      Updating the Computer Description Field in Active Directory with Computer Model Information The computer model information is generally displayed in the description field of the computer object in the Active Directory Users and Computers console. ...