Guess most of you are struggling with troubleshooting software update compliance and installing applications in Configuration Manager 2012. What I have found, is that clients in a reboot pending state often is the root cause to the problems. In previous posts I have described how you can use tools like Coretech Shutdown Utility to automatically restart computers that has been in a reboot pending state for X number of hours/days.
The information about the reboot pending state is stored in WMI Root\ccm\ClientSDK namespace as illustrated here with the Coretech WMI & PowerShell explorer:
Identify reboot state using PowerShell
Launch PowerShell ISE and type Invoke-WmiMethod -Namespace "ROOT\ccm\ClientSDK" -Class CCM_ClientUtilities -Name DetermineIfRebootPending
Notice RebootPending is True in the first example and False in the second example. Now let’s take the PowerShell command and turn it into a Compliance rule in Configuration Manager 2012.
Create the Compliance rule in Configuration Manager
- Launch the Configuration Manager console, navigate to the Assetts and Compliance workspace, Compliance Settings, Configuration Items.
- Create a new Configuration Item, Select Windows and click Next.
- Select all Operating systems, and click Next.
- On Settings, click New. In Setting type, select Script and in Data select Boolean.
- On Discovery Script, click Add Script and type
- Select the Compliance Rule tab, and click New. Configure the following values to False and click OK.
- Finish the wizard. Notice that I’m not creating a remediation script as I do not want to force a reboot.
- Create a new Baseline, and add the Reboot Pending Configuration Item.
- Deploy the baseline to a device collection.
- Right click the baseline deployment, select Create New Collection, Non-compliant.
Invoke-WmiMethod -Namespace "ROOT\ccm\ClientSDK" -Class CCM_ClientUtilities -Name DetermineIfRebootPending | select-object -ExpandProperty "RebootPending" and click OK.