Check for a Pending Reboot on Windows
Checks Windows Update, Component Based Servicing (CBS) and pending file rename entries. Reports why a reboot is needed.
- Windows18
- macOS5
- Linux5
- Network3
- Disk and storage4
- Inventory4
- Security9
- Updates4
- Maintenance4
Script
$reasons = @()
if (Test-Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending') { $reasons += 'CBS' }
if (Test-Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired') { $reasons += 'WindowsUpdate' }
$pfro = Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager' -Name PendingFileRenameOperations -ErrorAction SilentlyContinue
if ($pfro) { $reasons += 'PendingFileRename' }
if ($reasons) { Write-Output "Reboot pending: $($reasons -join ', ')"; exit 1 } else { Write-Output 'No reboot pending.' }Run it on every device with Moftgate
- 01
Add the script
In the Moftgate console, open Scripts > New script and paste the code.
- 02
Select the OS
Select Windows as the target operating system.
- 03
Test it
Run it on one test device first and read the output.
- 04
Roll out
Send it to all targets by group, profile or tag. Each device result is recorded separately.
These may help too
List Recently Installed Windows Updates
Lists installed hotfixes with KB number and install date, newest first.
Windows · PowerShellClear the DNS Cache on Windows
Empties the DNS client cache. Use it when a site resolves to the wrong IP or a DNS record has just changed.
Windows · PowerShellReset the Windows Network Stack (Winsock and TCP/IP)
Resets the Winsock catalog and TCP/IP settings. Use it when the device cannot connect after a broken VPN or proxy install. A restart is required.
Manage scripts from one console
Target selection, a confirmation step, per-device output and an audit log. The first 200 endpoints are free for a year.