To find a computer is waiting for reboot to complete the Microsoft Update installation, I have found this information in Windows Update WMI object. This displays True (if Pending Reboot),or False (Not waiting for reboot).
(New-Object -ComObject Microsoft.Update.SystemInfo).RebootRequired
But this only runs on the local computer. I needed to collect Pending Reboot state of all of our servers. That’s when I found this Gem – PowerShell Module – written by Brian Wilhite at Here.
It’s perfect. First you need to install this module on your local computer. Run this command on a elevated PowerShell (Run-As Administrator).
Install-Module -Name PendingReboot
You can close the elevated PowerShell. Use this module on your script to find Pending Reboot state and why it needs reboot.
Here is the example how it works:
PS E:\> Import-Module PendingReboot
PS E:> Test-PendingReboot -ComputerName SFOExch01 -Detailed -SkipConfigurationManagerClientCheck
ComputerName : SFOExch01
ComponentBasedServicing : False
PendingComputerRenameDomainJoin : False
PendingFileRenameOperations : True
PendingFileRenameOperationsValue : {\??\C:\Program Files\Common Files\Microsoft Shared\ClickToRun\ApiClient.dll.bak, , \??\C:\Program Files\Common Files\Microsoft
Shared\ClickToRun\C2RINTL.en-us.dll.bak, …}
SystemCenterConfigManager :
WindowsUpdateAutoUpdate : False
IsRebootPending : True