
Key Takeaways
- Restarting your computer with PowerShell can be achieved using different methods, including scripts, scheduled tasks, and shortcuts.
- Understanding the PowerShell
Restart-Computercommand and its various parameters and flags are crucial to customize your restart process. - Troubleshooting common issues and following best practices can help ensure a smooth and successful restart process.
- While PowerShell is a recommended option, there are alternative methods available to restart your computer.
Restarting a Remote Computer using PowerShell
Restart-Computer -ComputerName <computer-name>
Replace computername with the name or IP address of the remote computer you want to restart.
#Get credentials to connect $cred = Get-Credential #Restart remote computer Restart-Computer -ComputerName <Computer-Name> -Credential $Creds -Force
This command will prompt you to enter your credentials. Once done, the Restart-Computer command initiates the restart process.
Restart-Computer -ComputerName "Server1","Server2","Server3" -Force
This restarts the computers Server1, Server2, and Server3 without confirmation prompts.
Restarting the Computer using a Shortcut with PowerShell
If you find yourself needing to restart your computer frequently, creating a shortcut on your desktop can be a convenient way to initiate the process quickly and easily. This section will guide you through the steps to create a desktop shortcut that executes a PowerShell command to restart your computer.
Step 1: Create a PowerShell Script
Save the file as Restart.ps1 on your desktop.
Step 2: Create a Desktop Shortcut
Right-click on an empty area of your desktop and select New and then Shortcut. This will open the Create Shortcut wizard.
powershell.exe -ExecutionPolicy Bypass -File C:\Users\YourUserName\Desktop\Restart.ps1
Click Next and give your shortcut a name, such as “Restart Computer”. Click Finish to create the shortcut.
You can pin the shortcut to the Start menu or taskbar for quick access. Right-click on the shortcut and select Pin to Start or Pin to Taskbar.
Using the Shortcut to Restart Your Computer
Now that you have created the shortcut, using it to restart your computer is as simple as double-clicking on the icon. PowerShell will execute the Restart.ps1 script and restart your computer.
Writing a PowerShell Script to Restart the Computer
If you need to restart your computer frequently, creating a PowerShell script can save you time and effort. A script is a set of commands that can be executed together, automating a specific process. In this section, we will guide you on how to create a simple PowerShell script to restart your computer with ease.
Step 1: Open PowerShell ISE or Visual Studio Code (Or any other text editor)
Step 2: Write the Script
Once PowerShell ISE is open, you can start writing your script. In this case, we want to create a script that restarts the computer. To do so, we will use the Restart-Computer command, which we discussed in the previous section.
This command will restart the computer immediately without any warning.
Step 3: Save the Script
Once you have written your script, you need to save it. To do so, click on File > Save As in PowerShell ISE, and choose a name and location for your script. It is recommended to save the file with a .ps1 extension, which identifies it as a PowerShell script.
For example, you can save the file as “Restart-Computer.ps1” in the Documents folder.
Step 4: Run the Script
This command will execute the Restart-Computer script that you just created. Alternatively, you can create a shortcut to the script on your desktop or taskbar for easy access.
Restarting the Computer with PowerShell and a Scheduled Task
If you want to schedule a computer restart for a specific time or condition, PowerShell combined with a scheduled task can help you achieve that. This section will guide you through the steps to create a scheduled task that will automatically restart your computer.
Step 1: Creating a Scheduled Task
To create a scheduled task, open the Task Scheduler on your local computer by searching for “task scheduler” in the Start menu. Click on “Create Task” in the right-hand panel and give your task a name and a description.
Step 2: Configuring the Scheduled Task
Under the “Triggers” tab, create a new trigger for the task by clicking “New.” Choose the start date and time for the restart, and select the appropriate options for how often the task should run. Set the trigger to begin the task “At log on” or “On a schedule,” depending on your needs.
Under the “Actions” tab, add a new action to the task by clicking “New.” In the “Action” field, enter “powershell.exe” and in the “Arguments” field, enter the restart command for the remote computer using the “Restart-Computer” cmdlet.
Step 3: Testing and Troubleshooting
Once you have configured the scheduled task, test it by running the task manually or waiting for the scheduled time to arrive. If the task encounters any issues, use the Task Scheduler’s “History” tab to view the task’s status and any error messages that may have been generated.
When I run this basic PowerShell command: Restart-Computer -Force
- restart-computer -force
+ CategoryInfo : OperationStopped: (myComputer:String) [Restart-Computer], InvalidOperationException + FullyQualifiedErrorId : RestartcomputerFailed,Microsoft.PowerShell.Commands.RestartComputerCommand
The Microsoft article for this error here
says to download the update for your operating system. But it ends at Windows 2016 and says it will be auto-download and be installed with Windows updates. Doing a check for updates, says I am up to date. I tried to find the specific 2016 update KB4034674 just in case it may fix it, but the update is no longer on the Update Catalog.
I tried this stackoverflow article here
I stored the password in a password.bin file, and retrieved it, but it goes back to the above ‘Privilege not held’ error.
# Capture encrypted password once and store to file
$passwd = Read-Host "Enter password" -AsSecureString
$encpwd = ConvertFrom-SecureString $passwd
$encpwd > C:\Scripts\password.bin
# Afterwards always use this to start the script
$encpwd = Get-Content C:\Scripts\password.bin
$passwd = ConvertTo-SecureString $encpwd
$cred = new-object System.Management.Automation.PSCredential 'corp\myadmin',$passwd
Start-Process PowerShell -Cred $cred -ArgumentList "-noexit","-file C:\Scripts\Reboot.ps1"To add to my problem, Task Scheduler doesn’t work on this server. It got hosed somehow. I am using Task Till Dawn and tried using its built-in Restart and tried to run powershell script with it but it won’t work either.
Anybody know how to automatically reboot a Windows 2019 Server? This is kind of ridiculous
Exploring Alternatives to Restarting Computers with PowerShell
While PowerShell is a robust tool for restarting computers, there are alternative methods worth considering. In some cases, you may need to use other methods due to limitations or specific requirements.
Using the traditional Restart Method
The most straightforward approach to restart a computer is to use the traditional method of the Start menu. Click on the Start button, then select the Power icon, and finally choose Restart. This method is simple, convenient, and does not require any technical skills or commands.
Using the Command Prompt
If you prefer a command-line interface over PowerShell, you can use the Command Prompt to restart your computer. Open the Command Prompt by typing “cmd” in the Start menu search box, and hit Enter. Type the command “shutdown /r” to restart the computer instantly. You can also specify a time delay by adding the time value in seconds after the /t switch, like this: “shutdown /r /t 60” to restart the computer after 60 seconds.
Using Third-Party Tools
There are various third-party tools available that can help you restart your computer. Some of the popular examples include Reboot, Shutdown Timer, and Auto Power-on & Shutdown, among others. These tools offer additional features like scheduling, customization, and automation, which can be useful for specific scenarios.
Using the BIOS or UEFI Settings
If you are experiencing issues with the operating system or need to reset the computer entirely, you can use the BIOS or UEFI settings to restart the computer. Restarting from the BIOS or UEFI settings will erase all the data on the hard drive and restore the computer to its default settings. However, this method requires technical knowledge and can be risky if incorrectly executed.
Troubleshooting Common Issues with Restarting Computers using PowerShell
Restarting computers using PowerShell is generally a straightforward process, but there may be instances where you encounter issues that prevent a successful restart. In this section, we will outline some common problems that you may face and provide solutions to help you overcome them.
Error Messages
When attempting to restart your computer with PowerShell, you may encounter error messages such as “Access is denied” or “The service cannot accept control messages at this time.” These can often indicate that you do not have the necessary permissions to restart the computer or that a particular service is not responding.
Connectivity Issues
If you are attempting to restart a remote computer using PowerShell, connectivity issues can arise that prevent a successful restart. These issues can include network problems, firewalls, or incorrect credentials.
To resolve connectivity issues, you can try checking your network settings, verifying your credentials, and ensuring that the target computer is connected to the network. You can also try using the Test-Connection command to troubleshoot network connectivity.
Hanging or Frozen System
In some cases, attempting to restart the computer with PowerShell may cause the system to hang or become frozen. This can be caused by processes or applications that are not responding or services that are preventing a clean restart.
To resolve this issue, you can try closing any open applications or processes manually before using PowerShell to restart the computer. You can also try using the -Force flag with the Restart-Computer command to terminate all running processes and services forcefully.
Insufficient Resources
If your computer does not have sufficient resources to complete a restart process, you may encounter issues such as slow performance or system crashes. This can be caused by low memory or disk space, or by too many running applications or processes.
To resolve this issue, you can try closing any unnecessary applications or processes before using PowerShell to restart the computer. You can also try freeing up disk space or adding more memory to your system.
Best Practices for Restarting Computers with PowerShell
1. Understand the Restart-Computer Command
Before executing the restart process, it is crucial to understand the PowerShell Restart-Computer command and its different parameters. By knowing the command, you can customize the restart process according to your specific needs. Some of the commonly used parameters include -Force, -Credential, -Timeout, and -Wait.
2. Test the Restart Process in a Safe Environment
Prior to restarting a computer using PowerShell, it is advisable to test the restart process in a safe environment. This can help you identify any issues or errors that may arise during the process. For instance, you can test the restart process on a virtual machine or a non-critical device before executing it on the actual computer.
3. Use the -Force Parameter with Caution
The -Force parameter in the Restart-Computer command can be helpful in some scenarios, such as when there are unresponsive programs or services that prevent a normal restart. However, it should be used with caution as it can result in data loss or other complications. Before using the -Force parameter, ensure that you have saved all important files and closed all necessary applications.
4. Add a Timeout Value
When executing the restart process with PowerShell, it is recommended to add a timeout value to avoid any unexpected delays or errors. The -Timeout parameter allows you to specify the time duration in seconds for the computer to complete the restart process.
5. Verify the Restart Status
To ensure that the restart process is successful, it is important to verify the restart status of the computer. You can do this by using the Test-Connection command or by checking the event log for any relevant entries. Verifying the restart status can help you identify any issues that may have occurred during the process.
6. Use PowerShell Scripts for Automating the Restart Process
If you need to restart computers frequently, it can be helpful to create PowerShell scripts that automate the restart process. This can save time and increase efficiency. However, ensure that the script is tested in a safe environment before executing it on multiple computers.
Understanding the PowerShell Restart-Computer Command

Restarting your computer is often necessary to apply updates or resolve issues caused by programs freezing or crashing. Instead of manually restarting the computer, you can use PowerShell to restart the computer from the command line. PowerShell provides a simple yet powerful command Restart-Computer cmdlet that allows you to restart the current or target computers.
The basic syntax for using the Restart-Computer command with the most common parameters is:
Restart-Computer [-ComputerName <String[]>] [-Force] [-Wait] [-Timeout <Int32>] [-For <WaitForServiceTypes>] [-Delay <Int32>] [-Credential <PSCredential>] [-WsmanAuthentication <String>] [-Protocol <String>] [-Confirm]
Here is the most common usage of the PowerShell Restart-Computer command to restart the computer:
| Command | Description |
|---|---|
| Restart-Computer | Restarts the local computer Immediately |
| Restart-Computer -ComputerName <name> | Restarts the remote computer specified by <name> |
| Restart-Computer -Force | Restarts the computer forcibly, without gracefully shutting down running applications |
The Restart-Computer command also has many other parameters and flags that can be used to customize the restart process according to specific needs. For example, the -Wait parameter can be used to wait for the restart process to complete before returning control to the console.
In the next sections, we will explore how to restart the computer using PowerShell in different scenarios, both locally and remotely.
Step 1: Open a PowerShell Session
Step 2: Verify Your Execution Policy
Set-ExecutionPolicy RemoteSigned
After running this command, you should be able to execute PowerShell scripts on your machine.
Step 3: Restart Your Computer
After executing this command, your computer will start the restart process. You may need to save any unsaved work before proceeding. If you want to get the confirmation, use the -confirm switch.
Restart-Computer -Confirm
By default, PowerShell will wait for the computer to finish any tasks and close all applications before restarting. If you want to force the restart without waiting for these tasks to complete, you can use the “-Force” parameter:
This will force the computer to restart immediately, bypassing any active tasks or open applications.
Restarting a Windows Server is crucial for applying updates, troubleshooting issues, and maintaining system performance. Regular restarts help ensure a server runs the latest software, resolves conflicts, and clears temporary files.
This tutorial explains how to restart a Windows server using different methods.

- A system running Windows Server.
- Access to the Command Prompt.
- Access to PowerShell.
Restarting a Windows server is essential for applying critical updates and patches that enhance security and performance. It helps resolve software conflicts and clears out temporary files, which improves system stability and speed. It also closes running processes that slow the system down and starts them up again. Restarting is also helpful in troubleshooting network connectivity issues and application errors.
Note: A full Windows server restart clears all processes, ensuring a fresh start. However, using Fast Boot reduces downtime by speeding up the startup process. Still, Fast Boot only applies after a complete shutdown, never when restarting the system. Fast Boot is also more relevant to client versions of Windows, while server environments often prioritize full resets for stability and performance. So, use Fast Boot for personal computers or lightweight server tasks and avoid it for critical servers, troubleshooting, and security-sensitive environments. To set up Fast Boot, access Power Options in Windows settings.
Shutdown vs. Restart
Restarting a Windows server closes all applications and processes, shuts down the system, and immediately powers it back on, ensuring a complete reset of all system components. However, shutting down powers it off completely.
Use shutdown for regular power-offs, especially when Fast Boot is enabled for faster startups. Use restart when applying updates, troubleshooting, or needing a complete system reset to clear temporary issues.
Soft vs. Hard Restart
A soft restart is the standard method for restarting Windows. It involves using the operating system’s built-in restart command or restarting through the Start menu, which closes all running applications and processes before restarting the system.
On the other hand, a hard restart, also known as a hard reboot or force restart, involves forcibly cutting power to the system by holding down the power button until the system shuts down or disconnecting the power source and then turning it back on again. This method is used when the system becomes unresponsive and cannot be restarted using the usual soft restart method.
How to Restart a Windows Server
Note: Save all work before restarting your server to avoid losing any data or halting the process.
Restart the Windows Server with the GUI
1. Click the Start menu.
2. Select the Power button.

3. Click Restart.

Restart Windows Server via Command Prompt
If the GUI is not installed or working, other options exist for restarting your Windows server. One of them is to use the Windows shutdown command. The Windows shutdown command allows you to shut down, restart, log off, or hibernate your computer from the command line. Its syntax is:
shutdown [options]The shutdown command has plenty of options, but the one relevant to this tutorial is -r. The –r option tells Windows to restart instead of shutting down.
To restart the Windows server, access the Command Prompt and enter:
shutdown –r
The command has no output, but it restarts the server.
Restart Windows Server via Windows Powershell
The Restart-Computer cmdlet in PowerShell is used to restart a computer. It provides options to specify the computer name, force the restart, wait for the restart to complete, add a delay before the restart, set a timeout period, and provide credentials if necessary. The command syntax with all available options is:
Restart-Computer [-ComputerName] [-Force] [-Wait] [-For ] [-Delay ] [-Timeout ] [-Credential ] [-Protocol ] [-Confirm] [-WhatIf]The command consists of:
[-ComputerName]. Specifies the name of the computer to restart.[-Force]. Forces the restart without prompting for confirmation.[-Wait]. Waits for the restart to complete before returning.[-For]. Specifies how long it takes for the restart to complete (in seconds).[-Delay]. Specifies a delay before initiating the restart (in seconds).[-Timeout]. Specifies a timeout period for the restart operation (in seconds).[-Credential]. Shows a user account with permission to restart the computer.[-Protocol]. Determines the protocol to use for the restart operation.[-Confirm]. Prompts for confirmation before executing the restart.[-WhatIf]. Shows what happens if the restart command runs without actually restarting the computer.
Restart-Computer
You can delay the restart for longer than the default five seconds. For example, delay the restart for 15 seconds with:
Restart-Computer –delay 15
Restart Remote Windows Server
Restart-Computer –ComputerName ["NAME_OF_SYSTEM"]Restart-Computer -ComputerName "Server01"
This command initiates a restart of the remote Windows server named “Server01”.
Restarting a Windows server is simple, and this article presents several different ways to do it.
Next, learn about the most important Windows cmd commands.
In PowerShell scripting, ensuring scripts continue after a reboot can be challenging, especially when managing configurations or updates that require a system restart. There are two primary strategies for local and remote execution environments to address this issue.
Let’s dive into how you can make your PowerShell scripts pick up right where they left off after a reboot, whether you’re working on your computer or handling tasks on remote machines.
Using Task Scheduler for Local Computers
To keep your PowerShell script running after a reboot on a local computer, use the Windows Task Scheduler.
This method sets up a task that starts after a restart, so you don’t have to manually restart your script.
Let’s dive into two practical examples of implementing the reboot-and-continue pattern with PowerShell, utilizing the Windows Task Scheduler.
Example 1: Run a Script Block After Reboot
# Initial actions
Write-Host "Performing initial actions before reboot..."
# Command to run a script block upon reboot
$scriptBlock = { Write-Host "This is the continuation after reboot."
}
# Convert script block to a Base64 encoded string to pass it to the scheduled task
$encodedCommand = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($scriptBlock.ToString()))
# Creating the scheduled task
$action = New-ScheduledTaskAction -Execute 'Powershell.exe' -Argument "-EncodedCommand $encodedCommand"
$trigger = New-ScheduledTaskTrigger -AtStartup
Register-ScheduledTask -Action $action -Trigger $trigger -TaskName "ContinueAfterReboot" -Description "My task to continue script execution after reboot"
# Restart the computer (uncomment in actual use)
Restart-Computer
Example 2: Run the Same or Another Script Based on a Registry Key
In the second example, the script checks for a registry key to determine if it’s the first run or a continuation after a reboot.
- If it’s the first run, it performs initial actions and schedules itself to run again after reboot.
- If it’s continuing after a reboot, it skips the initial part and proceeds with the next actions.
# Check for the registry key to determine if this is the initial run or continuation
if (Test-Path -Path "HKCU:\Software\Test\ISRun") { # This is a continuation after reboot Write-Host "Continuing with the next part of the script..." # Perform the next part of the script... # Clean up: Remove the registry key and scheduled task if no longer needed Remove-Item -Path "HKCU:\Software\Test\ISRun" Unregister-ScheduledTask -TaskName "ContinueAfterReboot" -Confirm:$false
}
else { # This is the initial run Write-Host "Performing initial actions..." # Set a registry key to indicate the script has run New-Item -Path "HKCU:\Software\Test" -Force New-ItemProperty -Path "HKCU:\Software\Test" -Name "ISRun" -Value "true" -PropertyType "String" -Force # Schedule this script to run after reboot $action = New-ScheduledTaskAction -Execute 'Powershell.exe' -Argument "-File `"$PSScriptRoot\$(Split-Path -Path $MyInvocation.MyCommand.Path -Leaf)`"" $trigger = New-ScheduledTaskTrigger -AtStartup Register-ScheduledTask -Action $action -Trigger $trigger -TaskName "ContinueAfterReboot" -Description "Task to rerun the script after reboot" # Restart the computer (uncomment in actual use)
Restart-Computer
}This example addresses a common scenario where a script needs to run in two stages, with a reboot in between, without manual intervention to restart it. The challenge is ensuring that the script knows if it’s running for the first time or continuing after a reboot.
The solution is to use the Windows Registry as a marker or flag to track the script’s execution state.
During the first run, the script performs its initial set of actions—these could include system diagnostics, pre-update tasks, or configurations that need to be applied before a reboot. It then creates a specific registry key (HKCU:\Software\Test\ISRun) to mark that the initial phase has been completed. Subsequently, it schedules itself (or another script) to run at the system’s next startup.
After the reboot, the scheduled task starts the script again, which first checks for the registry key.
If the key is there, it knows the initial phase is done and moves on to the next tasks—post-reboot configurations, cleanup operations, or any finalization steps required to complete the task.
After these actions conclude, the script removes the registry key (and the scheduled task if necessary) to clean up and prevent it from running again on future reboots.
Using Restart-Computer for Remote Computer
For remote computers, it gets a bit easier with the Restart-Computer -Wait command. This command tells your script to wait until the computer has restarted before continuing.
Here’s how to use it:
Restart-Computer -ComputerName "RemotePC1", "RemotePC2" -Wait -For PowerShell -Timeout 600 -Delay 2
Managing reboot and continue operations for remote computers can be done by using the Restart-Computer cmdlet, enhanced with the -Wait parameter. This parameter pauses the script’s execution until the specified remote computers have completed their restart process.
However, it’s important to note the limitations when applying this method to the local computer.
According to Microsoft’s documentation, the -Wait parameter does not apply when restarting the local machine itself. If you include both remote and local computer names in the ComputerName parameter, the cmdlet issues a non-terminating error for the local machine while appropriately waiting for the remote machines to reboot.
This command restarts RemotePC1 and RemotePC2 and waits up to 600 seconds (10 minutes) for them to restart and continue running the script, checking every 2 seconds to see if they’re back online.
Conclusion
By using these methods, you can automate tasks that need a restart without manual intervention.
Whether you’re deploying software updates or making system changes, these techniques ensure your PowerShell scripts continue execution seamlessly after a reboot, making the process smoother and more efficient.
Popular Articles
Conclusion
I hope this guide has provided you with the necessary knowledge to use PowerShell to restart your computer. By applying the methods and best practices outlined in this guide, you can confidently resolve technical issues and improve system performance.
How can I restart my computer using PowerShell?
What is the PowerShell Restart-Computer command?
The PowerShell Restart-Computer command is a built-in cmdlet that allows you to restart a computer from within a PowerShell session. It provides various parameters and flags that allow you to customize the restart process.
How do I write a PowerShell script to restart the computer?
How can I create a shortcut to restart the computer using PowerShell?
Can I schedule a computer restart using PowerShell?
How do I troubleshoot common issues when restarting computers using PowerShell?
How to Shutdown a Computer using PowerShell?
To shut down a computer using PowerShell, you can use the Stop-Computer cmdlet: Stop-Computer -ComputerName localhost. Similarly, to Shut down a remote computer, use: Stop-Computer -ComputerName "Server01"


