The Pending Reboot Nightmare… PowerShell to the Rescue!
- Ben Liebowitz
- 5
- 4673
My company has been having issues dealing with servers in a pending reboot state for quite a while. Part of it stems from using SCCM to deploy patches and having the patch deployment set to suppress the reboot and our Operations Team reboots the servers manually. Well, some months require multiple reboots and we get stuck in the rabbit hole trying to get caught up by the next month’s round of patching!
I found a PowerShell Module that I’ve found VERY handy in finding the Pending Reboot State of servers.
The module is called, “PendingReboot” and can be installed from the PowerShell Gallery!
Install-Module PendingReboot -Confirm:$false
The cmdlet to use to check the pending reboot state of your servers is: Test-PendingReboot
NAME
Test-PendingReboot
SYNOPSIS
Test the pending reboot status on a local and/or remote computer.
SYNTAX
Test-PendingReboot [[-ComputerName] <String[]>] [-Credential <PSCredential>] [-Detailed]
[-SkipConfigurationManagerClientCheck] [-SkipPendingFileRenameOperationsCheck] [<CommonParameters>]
DESCRIPTION
This function will query the registry on a local and/or remote computer and determine if the
system is pending a reboot, from Microsoft/Windows updates, Configuration Manager Client SDK, Pending
Computer Rename, Domain Join, Pending File Rename Operations and Component Based Servicing.
ComponentBasedServicing = Component Based Servicing
WindowsUpdate = Windows Update / Auto Update
CCMClientSDK = SCCM 2012 Clients only (DetermineifRebootPending method) otherwise $null value
PendingComputerRenameDomainJoin = Detects a pending computer rename and/or pending domain join
PendingFileRenameOperations = PendingFileRenameOperations, when this property returns true, it can be a false positive
PendingFileRenameOperationsValue = PendingFilerenameOperations registry value; used to filter if need be, Anti-Virus will leverage this key property for def/dat removal, giving a false positive
RELATED LINKS
Background:
https://blogs.technet.microsoft.com/heyscriptingguy/2013/06/10/determine-pending-reboot-statuspowershell-style-part-1/
https://blogs.technet.microsoft.com/heyscriptingguy/2013/06/11/determine-pending-reboot-statuspowershell-style-part-2/
Component-Based Servicing:
http://technet.microsoft.com/en-us/library/cc756291(v=WS.10).aspx
PendingFileRename/Auto Update:
http://support.microsoft.com/kb/2723674
http://technet.microsoft.com/en-us/library/cc960241.aspx
http://blogs.msdn.com/b/hansr/archive/2006/02/17/patchreboot.aspx
CCM_ClientSDK:
http://msdn.microsoft.com/en-us/library/jj902723.aspx
REMARKS
To see the examples, type: “get-help Test-PendingReboot -examples”.
For more information, type: “get-help Test-PendingReboot -detailed”.
For technical information, type: “get-help Test-PendingReboot -full”.
For online help, type: “get-help Test-PendingReboot -online”
Here, I ran the command against a VM that I already knew to be in a pending reboot state.
Test-PendingReboot -ComputerName (Get-VM VM1)
RESULTS:
ComputerName IsRebootPending
———— —————
VM1 True
I love that I can use this against my already connected VMware vCenter servers and query via SRM Tiers, Storage Tiers, etc.
Test-PendingReboot -ComputerName (get-folder "SRM_Tier_01" | Get-VM)
RESULTS:
ComputerName IsRebootPending
———— —————
Server1 True
Server2 False
Server3 False
Or you can do it by Datastore Cluster
Test-PendingReboot -ComputerName (Get-DatastoreCluster "DatastoreCluster1" | Get-VM)
RESULTS:
ComputerName IsRebootPending
———— —————
Server4 False
Server5 True
Server6 True
This made my life a whole lot easier. 🙂
I hope someone else finds this handy like I did!
Ben Liebowitz, VCP, vExpert
NJ VMUG Leader
5 thoughts on “The Pending Reboot Nightmare… PowerShell to the Rescue!”
Leave a Reply Cancel reply
This site uses Akismet to reduce spam. Learn how your comment data is processed.
Thanks, Ben!
You’re most welcome!
can this be piped out into a csv or excel file ?
Hello,
I realised my first comment was not very polite. This module is brilliant I am just starting to try it out, I am new to powershell and wondered is it possible to get the results out to csv or excel please?
No worries, Marc.
You should be able to pipe it out to a CSV. I haven’t tried.
Test-Pendingreboot -Computername (Get-VM VM1) | export-csv -notypeinformation c:\pendingreboot.csv