Short answer: to reboot Windows from PowerShell, run Restart-Computer in an elevated window. Add -Force when other signed-in users or open programs would block it. From Command Prompt, shutdown /r /t 0 does the same. To restart a single service instead of the whole machine, run Restart-Service NAME, adding -Force when other services depend on it.
Restart-Computer # reboot this machine
Restart-Computer -Force # reboot even with other users signed in
shutdown /r /t 0 # the same from cmd, immediately
Restart-Service -Name W32Time # restart one service, not the machineThis page is written from Microsoft Learn’s reference for Restart-Computer, shutdown, Restart-Service, Stop-Service and Get-Service, as of October 2026, plus PowerShell’s source code for what -Force does to dependent services. Windows Server 2016 to 2025 ship Windows PowerShell 5.1, where every command below works.
PowerShell reboot cheat sheet
| Task | PowerShell | cmd |
|---|---|---|
| Restart now | Restart-Computer | shutdown /r /t 0 |
| Restart even if users are signed in | Restart-Computer -Force | shutdown /r /f /t 0 |
| Restart in 10 minutes | Start-Sleep 600; Restart-Computer | shutdown /r /t 600 |
| Cancel a pending restart | (none) | shutdown /a |
| Restart another server | Restart-Computer -ComputerName web02 | shutdown /r /m \\web02 /t 0 |
| Shut down (stays off) | Stop-Computer | shutdown /s /t 0 |
| Restart one service | Restart-Service W32Time | net stop W32Time && net start W32Time |
| Restart a service that has dependants | Restart-Service WAS -Force | (net stop asks first) |
| When did it last boot? | (Get-CimInstance Win32_OperatingSystem).LastBootUpTime | systeminfo | find "Boot Time" |
Restart-Computer and its parameters
Restart-Computer on its own restarts the local machine through WMI’s Win32Shutdown method, which needs the “Shut down the system” right that administrators have, so run it as an administrator. It returns no output; your session simply ends.
-Force
Without -Force, the restart is refused while other users are signed in, with the message The system shutdown cannot be initiated because there are other users logged on to the computer. On a server with several RDP sessions that is the usual reason a plain Restart-Computer does nothing. -Force restarts immediately, closing programs and sessions without asking, so unsaved work in other sessions is lost. Run quser first to see who is signed in.
-ComputerName and -Credential
Restart-Computer -ComputerName web02, web03 -Credential (Get-Credential) -Force-ComputerName takes names or IP addresses and does not need PowerShell remoting, but the remote server’s firewall has to let Windows management traffic in. On a server that faces the internet that traffic is usually, and rightly, blocked. Over the internet, connect with RDP and run the command locally instead.
-Wait, -For, -Timeout and -Delay
# restart web02, then wait up to 5 minutes until PowerShell remoting answers again
Restart-Computer -ComputerName web02 -Wait -For PowerShell -Timeout 300 -Delay 2
Invoke-Command -ComputerName web02 { Get-Service W3SVC }-Waitblocks until the remote computer is back, which makes restart-then-continue scripts possible. It is not valid for the local computer: a machine cannot wait for its own reboot.-Forchooses what “back” means:Wmi,WinRMorPowerShell(a remote session works).-Timeoutcaps the wait in seconds; without it,-Waitwaits indefinitely.-Delayis the most misread parameter: it is not a countdown before the restart. It sets how often, in seconds, PowerShell polls the restarted computer while waiting (default 5), and only works together with-Waitand-For. For a delayed restart useshutdown /r /t 600orStart-Sleep.
-WhatIf shows what would happen without restarting, and -Confirm asks first, which is a sensible habit in scripts that loop over server names. Since PowerShell 7.1, Restart-Computer also exists on Linux and macOS, where it simply calls /sbin/shutdown and accepts none of these parameters; the Linux side is covered in the Linux reboot and shutdown commands.
shutdown /r: the cmd way, with a delay and a reason
shutdown /r /t 0 # restart now
shutdown /r /t 600 /c "Updates installed, back in a few minutes"
shutdown /r /t 60 /d p:4:1 /c "App maintenance" # planned: Application, Maintenance
shutdown /a # abort a pending restart
shutdown /s /t 0 # shut down instead of restart| Switch | Meaning |
|---|---|
/r | Restart after shutting down |
/s | Shut down and stay off |
/t N | Wait N seconds first: 0 to 315360000 (10 years), default 30. Any value above 0 implies /f |
/f | Close running applications without warning; unsaved data is lost |
/c "text" | Comment shown to users and logged, up to 512 characters |
/d p:xx:yy | Reason code; p marks it as planned (p:4:1 is Application: Maintenance) |
/a | Abort a pending shutdown or restart during the countdown |
/m \\name | Target another computer |
/o | With /r: restart into the advanced boot options menu |
Every restart that a user or a program starts is logged as event 1074 in the System log, with the account, the program and your /c comment, which answers “who rebooted the server?” a week later:
Get-WinEvent -FilterHashtable @{LogName='System'; Id=1074} -MaxEvents 5 |
Format-List TimeCreated, MessageStop-Computer: shutting down instead
Stop-Computer (or shutdown /s) powers Windows off, and it takes -Force and -ComputerName like its sibling. On a remote server think twice: nothing you can type afterwards turns it back on. On a VPS it stays off until you press Start in the provider’s panel.
Restart-Service: restart one service, not the server
Most “have you tried turning it off and on again” moments on a server only need one service restarted. Restart-Service sends a stop and then a start to the Service Control Manager; a service that was already stopped is simply started. -Name wants the short service name, -DisplayName the long one (wildcards work in both). Look the name up first:
Get-Service -DisplayName "*time*" # find the short name from the display name
Restart-Service -Name W32Time -PassThru # restart and show the new status
Status Name DisplayName
------ ---- -----------
Running W32Time Windows Time-Force and dependent services
When other running services depend on the one you restart, Restart-Service refuses with Cannot stop service 'Windows Process Activation Service (WAS)' because it has dependent services. It can only be stopped if the Force flag is set. Look at what would go down with it, then add -Force:
Get-Service -Name WAS -DependentServices # e.g. W3SVC, the IIS web server
Restart-Service -Name WAS -ForceMicrosoft Learn describes -Force on Restart-Service only as running without confirmation, but in PowerShell’s code it is the same switch that Stop-Service documents as stopping a service that has dependants. The restart then starts again every dependant that was running before, so IIS comes back with WAS. Dependants that were already stopped stay stopped.
Get-Service and Where-Object: which services are running?
Get-Service | Where-Object {$_.Status -eq 'Running'}
# automatic services that are not running: a quick health check after a reboot
Get-Service | Where-Object {$_.StartType -eq 'Automatic' -and $_.Status -ne 'Running'} |
Select-Object Name, DisplayName, StatusThe second list is rarely empty: some automatic services stop on their own once their work is done. Look for the ones that matter to you, such as your web server, database or game server. A service stuck in Stopping for minutes can be ended by killing its process: Get-CimInstance Win32_Service -Filter "Name='NAME'" shows its ProcessId, and Stop-Process -Id PID -Force ends it. Check first that the process is not a shared svchost.exe hosting other services too.
How do I check whether Windows needs a reboot?
# Windows Update's own answer: True means a restart is pending
(New-Object -ComObject Microsoft.Update.SystemInfo).RebootRequired
# the registry flags most reboot checks read
Test-Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending'
Test-Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired'
$null -ne (Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager' -Name PendingFileRenameOperations -ErrorAction SilentlyContinue)The first line asks the Windows Update Agent, whose RebootRequired property reports whether installed or removed updates still need a restart. The registry keys cover more: RebootPending is set by the component servicing stack (features, roles and cumulative updates), RebootRequired by Windows Update, and PendingFileRenameOperations lists files to replace at the next boot, which many installers use. That last one is noisy: it can stay set long after anything important is pending, so treat it as a hint, not a verdict.
What happens to your RDP session when you restart?
Restarting from inside a Remote Desktop session works fine; Windows ends every session, yours included, and the client shows a disconnection message or tries to reconnect for a while. On a typical VPS, Windows Server answers on RDP again after a minute or two. After updates, the “Working on updates” phase runs before the login screen and can add many minutes, and RDP stays unreachable until it ends.
- 1Save your work and check other sessions
quserlists everyone signed in. Their unsaved work goes with-Force. - 2Restart
Restart-Computer, orshutdown /r /t 0 /c "reason"if you want the reason in the log. - 3Wait, then reconnect
Give it a minute or two and connect again as before (the guide to connecting over RDP covers every client).
(Get-CimInstance Win32_OperatingSystem).LastBootUpTimeconfirms the reboot happened. - 4Not back after ten minutes?
Open the provider’s console and look at the screen: an update screen means wait, a login screen means RDP itself is the problem. The checklist in Remote Desktop can’t connect goes through it, and enabling RDP on Windows Server covers switching it back on from the console.
Scheduling a restart
For a one-off restart later today, shutdown /r /t SECONDS is enough, and shutdown /a cancels it. For a fixed time, or a weekly restart, register a scheduled task that runs as SYSTEM:
$action = New-ScheduledTaskAction -Execute 'shutdown.exe' -Argument '/r /t 0 /d p:0:0 /c "Scheduled restart"'
# once, tomorrow at 03:00
$trigger = New-ScheduledTaskTrigger -Once -At (Get-Date).Date.AddDays(1).AddHours(3)
# or every Sunday at 04:00:
# $trigger = New-ScheduledTaskTrigger -Weekly -DaysOfWeek Sunday -At 4am
Register-ScheduledTask -TaskName 'Planned restart' -Action $action -Trigger $trigger -User 'SYSTEM' -RunLevel HighestA one-time trigger in the past never fires, which is why the example computes tomorrow’s date instead of writing -At 3am. Remove the task afterwards with Unregister-ScheduledTask -TaskName 'Planned restart'.
Common errors and what they mean
| Message | Cause | Fix |
|---|---|---|
...cannot be initiated because there are other users logged on to the computer. | Other sessions are open | Restart-Computer -Force, after checking quser |
Access is denied or a missing privilege | The account lacks the shutdown right | Run it as an administrator |
A system shutdown has already been scheduled.(1190) | A shutdown /t countdown is running | shutdown /a, then run your command again |
Unable to abort the system shutdown because no shutdown was in progress.(1116) | Nothing to cancel, or the restart already began | Nothing; it is too late or not needed |
Cannot stop service ... because it has dependent services. | Running services depend on it | Add -Force |
Cannot find any service with service name 'X'. | You passed the display name to -Name | Get-Service -DisplayName "*part*" for the short name, or use -DisplayName |
...cannot be stopped due to the following error: Cannot open X service on computer '.'. | Not elevated | Run as Administrator |
Restarting a Windows VPS
Restart from inside Windows whenever you can. Restart-Computer and shutdown /r let Windows close programs, flush files and finish updates. The Restart button in the VMHeaven panel is the tool for when Windows no longer responds: it power-cycles the virtual machine, which is the equivalent of pressing a reset button, so programs get no chance to save anything.
On a Windows VPS you log in as Administrator, so every command here works without extra rights, and the VNC console in the panel shows the boot and the update screens that RDP cannot. That is the place to watch a restart that takes longer than expected, before you reach for the reset.
Frequently asked
How do I reboot a computer with PowerShell?
Run Restart-Computer in PowerShell as an administrator. Add -Force if other users are signed in or programs block the restart. For another machine add -ComputerName NAME, and -Wait -For PowerShell to wait until it is back. From Command Prompt, shutdown /r /t 0 does the same.
How do I restart a service in PowerShell?
Run Restart-Service -Name SERVICENAME in an elevated PowerShell, using the short service name that Get-Service shows. If other running services depend on it, add -Force; PowerShell then stops them too and starts them again after the service itself.
Does Restart-Computer -Delay wait before restarting?
No. -Delay sets how often, in seconds, PowerShell checks whether a remote computer is back while -Wait is waiting, and it only works together with -Wait and -For. To restart after a delay, use shutdown /r /t 600 for ten minutes, or Start-Sleep before Restart-Computer.
What happens to my RDP session when I restart Windows Server?
Windows ends every session, yours included, and the Remote Desktop client shows a disconnection. A plain restart usually lets you reconnect after a minute or two. After updates, Windows finishes them before the login screen appears, which can take much longer; if RDP is not back after about ten minutes, look at the server's console.