Moorfox

PowerShell automations · 2026-08-01

PowerShell: check if a Windows machine has a pending reboot

The script

Windows records a pending reboot in three separate places: the Component Based Servicing key, the Windows Update key, and the pending file rename list. The script checks all three and prints which ones are set; any one of them means updates or installs are waiting on a restart.

$cbs = Test-Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending'
$wu  = Test-Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired'
$pfr = $null -ne (Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager' -Name PendingFileRenameOperations -ErrorAction SilentlyContinue)
[PSCustomObject]@{
  ComponentServicing = $cbs
  WindowsUpdate      = $wu
  FileRenamePending  = $pfr
  RebootPending      = $cbs -or $wu -or $pfr
}

Notes before you run it

  • PendingFileRenameOperations is the noisiest of the three; AV updates and installers set it for trivialities. Treat it as a weaker signal than the other two.
  • A machine that shows a pending reboot for weeks is a machine whose updates are not actually applying; check uptime next (Fast Startup hides shutdowns that never reboot).

Run it on every machine, not one at a time.

Save any of these as a command in Moorfox and run it on a machine in one click, output and exit code captured, with no PSRemoting or WinRM setup. The agent runs it locally and reports back, even over the internet.

Request an invite