This guide explains the methods to “Shutdown” or “Restart” the system using “PowerShell” or “Command Prompt” by covering the following content:
- How to Shut Down or Restart the System Using PowerShell?
- How to Shut Down or Restart the System Using Command Prompt?
How to “Shut Down” or “Restart” the System Using “PowerShell”?
“PowerShell” is a command-line shell, configuration management framework, and scripting language developed by Microsoft. It offers advanced capabilities for system administration, configuration, and automation. To “Shut down” or “Restart” your system, follow these steps:
Step 1: Launch “PowerShell”
To open PowerShell, press the “Windows” key, enter “Windows PowerShell,” and trigger “Run as Administrator”:
Step 2: Shut Down the System
To shut down your system, use the following command and it will trigger the immediate “Shut down”:
In situations where you need to “Shut down” the system after a specific time, you can use the “Start-Sleep” command like this, and here the “60” stands for the time (in seconds) after which the system will shut down:
If the above commands do not work, there may be a probability that one of the programs/services is not responding which is causing the delay in the “Shut down”. To force a “Shut down”, you can use an additional “-Force” flag like this:
Step 3: Restart the System
To restart your system, use the below-stated command:
Likewise, to trigger a force “Restart”, use the “-Force” flag, as follows:
To “Restart” the system after a specified time, let’s say 30 seconds, we’d use the following command:
How to Shut Down or Restart the System Using “Command Prompt”?
“Command Prompt”, “CMD”, or “Command Line Interpreter” is a traditional command-line interface that has been a part of Windows for so many years. To shut down or restart your system via this approach, follow these steps:
Step 1: Launch “Command Prompt”
To open Command Prompt, press the “Windows” key, enter “CMD” and trigger “Run as administrator”:
Step 2: Shutdown the System
To shut down your system using the “Command Prompt”, use the following command:
After the above command is executed, you will see the following message saying that the system is going to “Shut down”:
If there is an app/service that is preventing the “Shut down”, use the “/f” flag to forcefully shut down the system:
Once executed, the system will forcefully shutdown after a few seconds:
The “Command Prompt” also enables the users to do a scheduled “Shut down”. Suppose you want to shut down your system after “10 minutes”, use the following command where “/t” stands for time and “600” is the seconds after which it will shut down:
If you want to cancel the scheduled “Shut down” instead, use the below-provided command that includes the “/a” flag to cancel the scheduled shutdown:
Step 3: Restart the System
To restart the system, you can use the same commands as discussed but replace “/s” with “/r”. Let’s begin with triggering a simple “Restart”:
Similarly, you can force a system “Restart” using the “/f” flag:
For a scheduled “Restart”, use the following command where “/t” represents the time (in seconds) after which the system restarts which is “300 seconds” in this case:
To cancel a scheduled “Restart”, use the “/a” flag like this:
Conclusion
To shut down a system using “PowerShell”, the cmdlet “Stop-Computer” is used and for the restart, the “Restart-Computer” command is utilized. In the “Command Prompt”, the command “shutdown /s” is used to shut down the system and for restart, the command “shutdown /r” is utilized. These commands can further be applied with the flags or options based on requirements. This guide explained the methods to “Shut down” or “Restart” a Windows system using “PowerShell” or “Command Prompt”.