| by Arround The Web | No comments

How to Restart Computer Using PowerShell

PowerShell supports a set of cmdlets to perform various operations on a local system. Using PowerShell, the most common and useful commands include Get-Invoke, Stop-Process, Get-Help, etc., which have different functionalities. Moreover, PowerShell provides a facility to restart the computer on both remote and local machines in the Windows Operating System. One can restart a computer by using various conditions supported by PowerShell.
In this article, you will explore two methods to restart the computer with the help of PowerShell. The following learning outcomes are expected:

  • Restart a computer using the Restart-Computer cmdlet.
  • Restart a computer using the Shutdown command.

Let’s dig into the details one by one.

Method 1: Restart the Computer Using the Restart-Computer Cmdlet

In PowerShell, the most common method of restarting the computer is by using the “Restart-Computer” command. For this method, it is recommended to use PowerShell as an administrator.
Before getting into details, have a look at the syntax of the Restart-Computer cmdlet.

Syntax

Restart-Computer [[-ComputerName] String[]] [-Force] [-Wait] [-Timeout] [-Delay] [-CommonParameters]

The following parameters would be helpful in applying the Restart-Computer cmdlet.

  • ComputerName: Write the name of the system for restarting.
  • Force: The parameter forcefully executes the command.
  • Wait: It blocks the prompt messages until the timeout.
  • Timeout: Specify the time to execute the action.
  • Delay: The parameter delays the restart process using the Restart-Computer cmdlet.

Using the Restart-Computer cmdlet, an example is explained here to restart a computer.
The following command will restart the local computer instantly.

Restart-Computer

In the above code, the simplest command, “Restart-Computer,” is used to restart the operating system.

Output

You will observe that the computer is restarted instantly.

Method 2: Restart the Computer Using the Shutdown Command

This command can be employed to restart the computer. The syntax of utilizing the Shutdown command is provided below.

Syntax

Shutdown [parameters]

The following set of parameters can be utilized with the Shutdown command.

  • /r: To restart the computer.
  • /s: This option is specified to shut down the system using PowerShell.
  • /l: To log off the computer.
  • /h: Shifts the computer to hibernate mode.

Let’s exercise an example to restart the computer using the Shutdown command. The command is executed in an administrative privilege’s environment:

Shutdown /

When you execute the command, a prompt will appear containing a set of options available for the Shutdown command.
You can directly restart your computer using the below-mentioned shutdown command:

Shutdown /r

When the command is executed, your computer will be restarted within a minute.
That’s all from this article!

Conclusion

In PowerShell, one can restart the computer using the Restart-Computer cmdlet and the Shutdown command. In the Restart-Computer cmdlet, various parameters are used, such as Delay, Force, and Timeout, to execute the process according to the user’s needs. The Shutdown cmdlet provides the /r to restart the computer using PowerShell. Both of these cmdlet methods are utilized to restart the computer using PowerShell.

Share Button

Source: linuxhint.com

Leave a Reply