Windows Update Stuck on Checking for Updates I was looking at Windows Update under my settings to make sure I was up to date, but it seems Windows Update has been stuck checking for updates. I looked into the Windows Update Troubleshooter, and it's currently been 'Checking for pending restart' for a good 10+ minutes now. The automated install is sitting at a point where 'reboot is required.' Is there a default place in the registry or some other trick to check if a reboot is pending so I can prompt the user via a script? You can use it both for checking if a full reboot is required because of kernel or core libraries updates (using the -r option), or what services need to be restarted (using the -s option). Needs-restarting -r returns 0 if reboot is not needed, and 1 if it is, so it is perfect to use in a script.
Module to detect Windows OS pending reboots.
If you’re trying to determine which of your servers require reboots, you’ll love this PowerShell script to check the status. It turns out that a simple way to identify servers that are pending reboot is to check the registry. This information is stored in the HKeyLocalMachine hive of the registry. convertkit form=949492. This article will go over the steps needed to check pending reboot statuses with Powershell. This is used to check or query WMI attributes and it works for Windows 10, Windows Server 2012 and Windows 2016. It also suppors reboots pending from SCCM.
![Checking Checking](/uploads/1/1/9/8/119875842/111594513.png)
Minimum PowerShell version
3.0
Installation Options
Copy and Paste the following command to install this package using PowerShellGet More Info
You can deploy this package directly to Azure Automation. Note that deploying packages with dependencies will deploy all the dependencies to Azure Automation. Learn More
Manually download the .nupkg file to your system's default download location. Note that the file won't be unpacked, and won't include any dependencies. Learn More
Author(s)
Brian Wilhite
Copyright
(c) 2018 Brian Wilhite. All rights reserved.
Package Details
Owners
Tags
Functions
Dependencies
This module has no dependencies.
FileList
- PendingReboot.nuspec
Version History
Version | Downloads | Last updated |
---|---|---|
0.9.0.6 (current version) | 7,189,421 | 8/22/2018 |
0.9.0.0 | 56 | 8/21/2018 |
If you’re trying to determine which of your servers require reboots, you’ll love this PowerShell script to check the status.
It turns out that a simple way to identify servers that are pending reboot is to check the registry.
This information is stored in the HKeyLocalMachine hive of the registry.
[convertkit form=949492]
PowerShell is perfect for working with the registry.
Registry is one of the built-in PowerShell providers!
There’s even already a PSDrive connected to that registry hive!
You can’t ask for anything more… except to maybe be able to map a new PSDrive to a different part of the Registry — which is ALSO super easy to do!
You can browse around the registryjust like you do with the filesystem.
Wow! Super easy, right?
Now you just need to know where the “pending reboot” location is. There are a couple of places to check.
- HKLMSOFTWAREMicrosoftWindowsCurrentVersionWindowsUpdateAuto UpdateRebootRequired
Is where patches installed through automatic updates register the need to reboot.
Checking For Pending Restart Troubleshooter
- HKLMSOFTWAREMicrosoftWindowsCurrentVersionComponent Based ServicingRebootPending
Is another place where pending reboots can be identified.
- HKLMSYSTEMCurrentControlSetControlSession Manager
Is yet another. Finally, there is Configuration Manager which, if present, can be queried via WMI.
Checking For Pending Restart Stuck
I found a function that I really like to check all four locations.
Checking For Pending Restart
I’ll need to wrap it up with some parameters to check remote computers, but in general it was a great start.
Clear Pending Restart Windows 10
I’ve adapted the function to return $true on the first condition that satisfies, since I only care about whether the computer is pending a reboot, and not where the source of the reboot is coming from.