momius - Fotolia

Get started Bring yourself up to speed with our introductory content.

How to use the PowerShell pending reboot module

Learn how to check if your machines have pending reboots with a simple PowerShell module to ensure changes to files do not cause stability issues.

You are likely accustomed to rebooting a Windows computer, and the PowerShell pending reboot module can make that process easier.

Windows requires a reboot to successfully finish operations, such as updating drivers and installing patches, third-party software and Windows features. A restart gives Windows the opportunity to change or remove files without causing instability.

You can check if Windows has a pending reboot with the PowerShell pending reboot module, created by Brian Wilhite, a Microsoft premier field engineer.

Get started with the pending reboot module

Use the PowerShell Gallery to install the PowerShell pending reboot module:

PS C:\> Install-Module PendingReboot

A restart gives Windows the opportunity to change or remove files without causing instability.

The module will be loaded into the current PowerShell session with the cmdlet Test-PendingReboot. While looking at the code inside of the PowerShell pending reboot cmdlet, you can see where the cmdlet checks for a pending reboot in the Windows registry. These locations map to component-based servicing (CBS), Windows Update, an Active Directory join and the System Center Configuration Manager software development kit (SCCM SDK).

The CBS stack was introduced with Windows Vista and encompasses various tools to service Windows while keeping the OS stable. CBS has several different levels for servicing. The first is for Windows Update, programs and features, and MSI. The second level is the trusted installer, which runs in Task Manager during certain installations. The last level is for kernel transactions to Windows.

How to use Test-PendingReboot

By default, when running the Test-PendingReboot cmdlet on the local system, it will return two properties: ComputerName and IsRebootPending.

How to use Test-PendingReboot

Note that SCCM does not manage the system, so the cmdlet cannot find the SCCM SDK in the registry. If you want to skip the cmdlet from checking, you can use the parameter –SkipConfigurationManagerClientCheck.

You can find more information from the cmdlet than pending reboots. If you run the cmdlet with the –Detailed parameter, it will give the status on all of the areas in the registry it checks.

If you run the cmdlet with the –Detailed parameter, it will give the status on all of the areas in the registry it checks.

For example, if you install Mozilla Firefox, Thunderbird and Acrobat DC, each will have a pending file renaming operation. The PendingFileRenameOperationsValue property can have multiple values, which you can see by piping Test-PendingReboot to Foreach-Object. The next reboot will rename the files.

The PendingFileRenameOperationsValue property can have multiple values, which you can see by piping Test-PendingReboot to Foreach-Object.

In addition to checking pending reboots locally, you can specify the –ComputerName parameter, which will use Invoke-WMIMethod to remotely connect and check the same registry values.

Use Get-ADComputer from the Active Directory module to retrieve computers to query:

Use Get-ADComputer from the Active Directory module to retrieve computers to query.

In the above command, first query Active Directory for any system under the organizational unit servers and then query them with Test-PendingReboot.

Dig Deeper on Windows administration tools

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchServerVirtualization

SearchCloudComputing

SearchSQLServer

SearchEnterpriseDesktop

SearchVirtualDesktop

Close