Checking For Pending Restart

Module to detect Windows OS pending reboots.

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. Remotely Check Pending Reboot Status Using Powershell Posted on August 7, 2018 by Paul In the world of system administration, you will eventually have a need to check if a server needs a reboot or simply check pending reboot status.

Checking For Pending Restart

Minimum PowerShell version

3.0

Installation Options

Copy and Paste the following command to install this package using PowerShellGet More Info

Checking For Pending Restart

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

VersionDownloadsLast 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.

Windows Pending Reboot Registry Key

[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

Windows Update Checking For Pending Restart

Is where patches installed through automatic updates register the need to reboot.

  • HKLMSOFTWAREMicrosoftWindowsCurrentVersionComponent Based ServicingRebootPending

Is another place where pending reboots can be identified.

  • HKLMSYSTEMCurrentControlSetControlSession Manager

Checking For Pending Restart Stuck Windows 10

Is yet another. Finally, there is Configuration Manager which, if present, can be queried via WMI.

I found a function that I really like to check all four locations.

I’ll need to wrap it up with some parameters to check remote computers, but in general it was a great start.

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.