T The Triage ManualTechnical Guides for IT Emergencies
P4 · Endpoint & Device Management

Identifying Windows Computers with Pending Reboot Status Using PowerShell

Windows systems that have received patches or updates but not restarted remain in a 'pending reboot' state, which can cause subsequent update failures, policy misapplication, and security exposure. PowerShell scripts can query specific registry keys (Component Based Servicing, Session Manager, Windows Update) to identify these systems across the domain. Results enable patch management teams to prioritise and enforce reboots within compliance windows.

Indicators

Likely causes

Diagnostic steps

  1. Identify the registry locations that indicate a pending reboot. Query the following keys: - HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending - HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations - HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired
    Understand which registry keys must be checked to determine if a reboot is pending before writing or running any script.
  2. Run a local test on a single machine using PowerShell: $rebootPending = Test-Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending' $rebootRequired = Test-Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired' $pendingFileRename = (Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager' -Name PendingFileRenameOperations -ErrorAction SilentlyContinue).PendingFileRenameOperations if ($rebootPending -or $rebootRequired -or $pendingFileRename) { Write-Output 'Reboot Pending' }
    Validate that the detection method works correctly on a known machine (one with a pending reboot and one without) before remote deployment.
  3. Scale to the domain using PowerShell remoting: $computers = Get-ADComputer -Filter * | Select-Object -ExpandProperty Name $results = Invoke-Command -ComputerName $computers -ScriptBlock { $cbsReboot = Test-Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending' $wuReboot = Test-Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired' $pfro = (Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager' -Name PendingFileRenameOperations -EA SilentlyContinue).PendingFileRenameOperations [PSCustomObject]@{ ComputerName = $env:COMPUTERNAME CBSRebootPending = $cbsReboot WURebootRequired = $wuReboot PendingFileRename = [bool]$pfro } } -ErrorAction SilentlyContinue
    Query all domain computers to produce a comprehensive list of systems in a pending reboot state.
  4. Filter and export results to CSV: $results | Where-Object { $_.CBSRebootPending -or $_.WURebootRequired -or $_.PendingFileRename } | Export-Csv -Path 'C:\Reports\PendingReboots.csv' -NoTypeInformation
    Produce actionable output that operations or patch management teams can use to prioritise and schedule reboots.

Resolution path

Prevention

Tools

References

pending-rebootwindows-updatepatch-managementpowershellregistryactive-directorycompliancewsussccmmecmintuneendpoint-managementwindows-serverwindows-10windows-11reboot-requiredsecurity-updatescbscomponent-based-servicing