PowerShell / ConfigMgr 2012: Check Client Reboot Pending State


If you’ve worked with Configuration Manager 2007 for very long, you probably know that clients pending reboots can cause you quite a headache. Determining whether or not a client needs a reboot can be a challenging task, and most folks used desired configuration management rules to detect it.

Well, I’m happy to announce that there’s a new method of figuring out whether or not a SCCM client requires a reboot! There’s a new WMI namespace called rootccmClientSDK, and within it is a WMI class called CCM_ClientUtilities, which has a static method called DetermineIfRebootPending() – the method does not take any input parameters, however it spits out several [out] parameters when it is called.



Output Parameters



The DetermineIfRebootPending() method can be easily called from Windows PowerShell, which tightly integrates with WMI (Windows Management Instrumentation). It’s a very simple, two-step process:

  1. Get a reference to the CCM_ClientUtilities WMI class
  2. Call the DetermineIfRebootPending() method

Here is what the code would look like:

PS C:Usersts> $clientutils = [wmiclass]"rootccmclientsdk:CCM_ClientUtilities"
PS C:Usersts> $clientutils.DetermineIfRebootPending()

__GENUS             : 1
__CLASS             : __PARAMETERS
__SUPERCLASS        :
__DYNASTY           : __PARAMETERS
__RELPATH           : __PARAMETERS
__DERIVATION        : {}
__SERVER            : SCCM02
__NAMESPACE         : ROOTccmClientSDK
__PATH              : \SCCM02ROOTccmClientSDK:__PARAMETERS
DisableHideTime     : 19691231180000.000000+000
InGracePeriod       : False
IsHardRebootPending : False
RebootDeadline      : 19691231180000.000000+000
RebootPending       : False
ReturnValue         : 0

As you can see, we get several useful properties returned to us, specifically the IsHardRebootPending and RebootPending.