Or copy link
Copy link
If you’re looking for a simple guide on how to restart server processes properly, this article will walk you through every step. Rebooting a Windows Server is a trivial task, and it is regularly needed after several events such as upgrades, changes in configuration, and issues with performance. A reboot properly terminates processes and unmanaged resources, nullifies memory, reloads services, and stabilizes the system. Not rebooting in a timely fashion can contribute to slower processes and services not being available.
PowerShell enables an easy and scriptable approach to rebooting a host (server). It allows for rebooting a server with no manual intervention and reasonably shortens downtime by allowing for automation or remote execution. The administrator can reboot one or more servers while not needing to use a GUI or an external application.
This option is supported on all Windows Server versions 2016, 2019, and 2022. PowerShell supports both local and remote reboots which is ideal for an administrator with physical or virtual servers in a larger scale enterprise like environment.
In this article, we will explain step-by-step with examples how to reboot a server using PowerShell, both locally and remotely.
Restart Windows Server Remotely with Ease on UltaHost VPS!
Manage Windows Server reboots smoothly using PowerShell on UltaHost’s secure VPS. Experience fast response, full control, and reliable uptime for your enterprise tasks!
Before restarting a Windows Server using PowerShell, confirm that the following technical requirements are met.
You must run PowerShell as an administrator. Right-click on the PowerShell icon and select “Run as administrator”. Without elevated permissions, restart commands will fail.
PowerShell must allow script execution. To check the current policy, run:
Get-ExecutionPolicy
If the output is restricted, change it using:
Set-ExecutionPolicy RemoteSigned
Type Y and press Enter to confirm. This change allows locally written scripts to run while blocking unsigned remote scripts.
To restart a server remotely, enable remoting on the target machine:
Enable-PSRemoting -Force
This command starts the WinRM service, sets the startup type to automatic, and configures the firewall. Run it in an elevated PowerShell session on the target server.
These steps prepare both local and remote environments for safe and successful restarts using PowerShell.
To restart server from command line using PowerShell, use the Restart-Computer cmdlet. It works for local Windows Servers and requires admin privileges. This command performs a clean shutdown followed by a reboot. It is the standard PowerShell restart command for local systems.
Basic Syntax:
Restart-Computer
Running this command in an elevated PowerShell session will gracefully restart the server. It closes running applications, stops services, and initiates a safe reboot process.
Sometimes, the system might not restart because an application is frozen or not responding. If that happens, you can force the reboot using:
Restart-Computer -Force
This option skips the wait and forces everything to close immediately.
If you want to double-check before the system restarts, you can include the -Confirm flag. This prompts you to approve the action before it runs:
Restart-Computer -Confirm
If you want to preview what the command would do without actually restarting the server, you can use the -WhatIf flag:
Restart-Computer -WhatIf
It shows the expected outcome without executing anything, which is useful when testing scripts.
To restart a remote Windows Server, you can use the same Restart-Computer cmdlet with the -ComputerName parameter. Just replace “ServerName” with the name or IP address of the target machine:
Restart-Computer -ComputerName "Server01"
This will send a remote restart request to the specified server. Make sure PowerShell remoting is enabled on the remote system.
If your current session doesn’t have permission to access the remote server, add the -Credential flag to supply a valid username and password:
Restart-Computer -ComputerName "Server01" -Credential (Get-Credential)
This will prompt you to enter login credentials for the remote machine.
You can also use Enter-PSSession to connect directly to a remote server and run commands interactively:
Enter-PSSession -ComputerName "Server01" Restart-Computer
Or use Invoke-Command to send a restart instruction without entering a full session:
Invoke-Command -ComputerName "Server01" -ScriptBlock { Restart-Computer -Force }
Before using any of these methods, ensure that Windows Remote Management (WinRM) is enabled and that the firewall allows remote PowerShell traffic. These steps are required for a successful remote restart using PowerShell.
To perform a batch restart across multiple servers, you can pass an array of server names to the Restart-Computer cmdlet. This is useful in enterprise environments where you manage many systems at once.
Here’s a simple PowerShell script for server restart in bulk:
$servers = @("Server1", "Server2") Restart-Computer -ComputerName $servers -Credential (Get-Credential)
This command prompts for credentials and then sends a restart request to all listed servers. PowerShell processes the restart in parallel, saving time and effort.
Using this method helps automate regular maintenance or apply updates across several machines without logging into each one manually. It’s efficient, especially when dealing with dozens or hundreds of servers in a network.
To schedule a reboot during off-hours, you can use the Task Scheduler through PowerShell with the schtasks.exe utility. This is helpful during maintenance windows or after update deployments when you want to avoid service disruptions.
Here’s an example that sets up a scheduled reboot at 2:00 AM:
schtasks.exe /Create /SC ONCE /TN "ScheduledRestart" /TR "shutdown.exe /r /f /t 0" /ST 02:00 /RU "SYSTEM"
This command creates a one-time task named “ScheduledRestart” that forces a reboot at 2:00 AM, using the system account.
You can also run this from a PowerShell script to automate reboots across multiple servers as part of a patching process. It’s a reliable way to handle reboots without manual intervention.
Read Also How to Install FTP Server on Windows
When restarting a server with PowerShell, you may encounter errors like Access Denied or RPC Server Unavailable. These issues often result from missing admin rights, firewall restrictions, or remoting not being enabled.
To handle such restart failures, wrap your command in a Try-Catch block:
try { Restart-Computer -ComputerName "Server01" -Credential (Get-Credential) } catch { Write-Error "Restart failed: $_" }
This approach catches any error and prints a clear message instead of stopping the script.
Also, verify that required services like WinRM are running and that no active user sessions or service dependencies are blocking the restart.
After restarting a server, it’s important to confirm it came back online. You can use the Test-Connection cmdlet to ping the server and check its availability:
Test-Connection -ComputerName "Server01" -Count 2
To automate the check, use a loop that pings until the server responds:
do { Start-Sleep -Seconds 5 } until (Test-Connection -ComputerName "Server01" -Quiet)
This waits in 5-second intervals until the server is reachable.
You can also run Get-Service remotely to verify if critical services are running:
Get-Service -ComputerName "Server01"
These simple checks help verify the reboot was successful and confirm the system is healthy. Use them as part of your server health check routine after every restart.
Here’s a complete PowerShell reboot script that restarts a remote server, handles errors, and checks when it comes back online:
$server = "Server01" $cred = Get-Credential try { Restart-Computer -ComputerName $server -Credential $cred -Force Write-Output "Restart command sent to $server" } catch { Write-Error "Restart failed: $_" exit } # Wait for server to respond do { Start-Sleep -Seconds 5 $online = Test-Connection -ComputerName $server -Quiet } until ($online) Write-Output "$server is back online"
This script automates restart, includes error handling, and confirms the server is back up. It uses Restart-Computer, Try-Catch, and Test-Connection to cover the full cycle.
You can also extend this script to write output to a log file or send an email notification for tracking purposes.
Restarting a Windows Server using PowerShell is a reliable and flexible approach for both local and remote systems. You’ve seen how to use the Restart-Computer cmdlet, handle multiple servers, schedule reboots, manage errors, and confirm that systems are back online. Each method supports specific needs—from one-time restarts to full automation scripts.
Choose the method that matches your environment. For single servers, a basic command may be enough. For large networks, automated scripts with error checks and scheduled tasks offer better control. PowerShell’s remote capabilities and scripting features save time, reduce manual work, and ensure consistency across your server infrastructure.
Experience UltaHost’s affordable Windows VPS hosting for smooth server management and reliable performance. UltaHost gives you full control with automated tools like PowerShell, while ensuring stable uptime and expert support every step of the way!
Use the Restart-Computer cmdlet in an elevated PowerShell session. It performs a clean shutdown followed by a reboot.
Yes, use Restart-Computer -ComputerName "ServerName" with remoting enabled. Add the -Credential flag if authentication is required.
Restart-Computer -ComputerName "ServerName"
-Credential
Ensure PowerShell remoting is enabled and WinRM is configured. Also, verify that firewall rules allow remote PowerShell traffic.
Add the -Force parameter to the command. It will close all processes and restart the system immediately.
-Force
Yes, use schtasks.exe to create a scheduled task that runs shutdown.exe. This lets you automate reboots during off-hours.
schtasks.exe
shutdown.exe
Use Test-Connection to ping the server. Loop the check until the server responds to confirm it’s back online.
Test-Connection
Wrap your command in a Try-Catch block to catch and display errors. Common issues include missing admin rights or disabled remoting.
Try-Catch
React Native is an open-source framework developed by F...
AnyDesk has become a popular choice for remote desktop ...
PyCharm is a powerful Integrated Development Environmen...
RubyMine is an integrated development environment (IDE)...
R is a popular programming language and software enviro...
Remote access to your Windows VPS stands for Virtu...
Save my name, email, and website in this browser for the next time I comment.
Δ