Introduction

The xPendingReboot module is a part of the Windows PowerShell Desired State Configuration (DSC) Resource Kit, which is a collection of DSC Resources produced by the PowerShell Team. This module contains the xPendingReboot resource. xPendingReboot examines three specific registry locations where a Windows Server might indicate that a reboot is pending and allows DSC to predictably handle the condition.

All of the resources in the DSC Resource Kit are provided AS IS, and are not supported through any Microsoft standard support program or service. The "x" in xPendingReboot stands for experimental, which means that these resources will be fix forward and monitored by the module owner(s).

Please leave comments, feature requests, and bug reports in the Q & A tab for this module.

If you would like to modify xPendingReboot module, feel free. When modifying, please update the module name, resource friendly name, and MOF class name (instructions below). As specified in the license, you may copy or modify this resource as long as they are used on the Windows Platform.

For more information about Windows PowerShell Desired State Configuration, check out the blog posts on the PowerShell Blog (this is a good starting point). There are also great community resources, such as PowerShell.org , or PowerShell Magazine . For more information on the DSC Resource Kit, check out this blog post.

Installation

To install xPendingReboot module

  • Unzip the content under $env:ProgramFiles\WindowsPowerShell\Modules folder

To confirm installation:

  • Run Get-DSCResource to see that xPendingReboot is among the DSC Resources listed

Requirements

This module requires the latest version of PowerShell (v4.0, which ships in Windows 8.1 or Windows Server 2012R2). To easily use PowerShell 4.0 on older operating systems, install WMF 4.0. Please read the installation instructions that are present on both the download page and the release notes for WMF 4.0.

Description

The xPendingReboot module containes the xPendingReboot resource, which examines three specific registry locations where a Windows Server might indicate that a reboot is pending, and allows DSC to predictably handle the condition. PowerShell Desired State Configuration determines how to handle pending reboot conditions using the Local Configuration Management setting RebootNodeIfNeeded. When DSC resources require reboot, within a Set statement in a DSC Resource the global variable DSCMachineStatus is set to value “1”. When this condition occurs and RebootNodeIfNeeded is set to “True”, DSC reboots the machine after a successful Set. Otherwise, the reboot is postponed.

Details

xPendingReboot resource has following properties:

  • Name:                                          REQUIRED parameter that must be unique per instance of the resource within a configuration.
  • ComponentBasedServicing:    Read-Only Property: One of the locations that are examined by the resource. Details are returned by Get-DSCConfiguration.
  • WindowsUpdate:                      Read-Only Property: One of the locations that are examined by the resource. Details are returned by Get-DSCConfiguration.
  • PendingFileRename:                 Read-Only Property: One of the locations that are examined by the resource. Details are returned by Get-DSCConfiguration.
  • PendingComputerRename:     Read-Only Property: One of thelocations that are examined by the resource. Details are returned by Get-DSCConfiguration.
  • CcmClientSDK:                            Read-Only Property: One of the locations that are examined by the resource. Details are returned by Get-DSCConfiguration.

Renaming Requirements

When making changes to these resources, we suggest the following practice:

  1. Update the following names by replacing MSFT with your company/community name and replacing the "x" with "c" (short for "Community") or another prefix of your choice:
    • Module name (ex: xPendingReboot becomes cPendingReboot)
    • Resource folder (ex: MSFT_xPendingReboot becomes Contoso_xPendingReboot)
    • Resource Name (ex: MSFT_xPendingReboot becomes Contoso_cPendingReboot)
    • Resource Friendly Name (ex: xPendingReboot becomes cPendingReboot)
    • MOF class name (ex: MSFT_xPendingReboot becomes Contoso_cPendingReboot)
    • Filename for the <resource>.schema.mof (ex: MSFT_xPendingReboot.schema.mof becomes Contoso_cPendingReboot.schema.mof)
  2. Update module and metadata information in the module manifest
  3. Update any configuration that use these resources

We reserve resource and module names without prefixes ("x" or "c") for future use (e.g. "MSFT_PendingReboot"). If the next version of Windows Server ships with a "PendingReboot" resource, we do not want to break any configurations that use any community modifications. Please keep a prefix such as "c" on all community modifications.

Versions

0.1.0.2

  • Documentation change, added information on PendingComputerRename and CcmClientSdk. No functional change.

0.1.0.1

  • Update with improvements to the Test- function, and how pending reboots are detected.

0.1.0.0

  • Initial release with the following resources
    • xPendingReboot

Example: Identify if reboots are pending and if so, reboot immediately (managed by DSC)

This configuration leverages xPendingReboot and sets the LCM setting to allow automatic reboots.

PowerShell
Edit|Remove
Configuration CheckForPendingReboot  
{         
    Node ‘NodeName’  
    {   
        xPendingReboot Reboot1 
        {  
            Name = ‘BeforeSoftwareInstall’ 
        } 
        LocalConfigurationManager 
        { 
            RebootNodeIfNeeded = 'True' 
        }  
    }   
}  
   
 

Example: Identify if reboots are pending but do not automatically reboot (managed by DSC)

This configuration will install the hotfix from a URI that is connected to a particular hotfix ID. This configuration leverages xPendingReboot and sets the LCM setting to allow automatic reboots..

 

PowerShell
Edit|Remove
Configuration CheckForPendingReboot  
{         
    Node ‘NodeName’  
    {   
        xPendingReboot Reboot1 
        {  
            Name = ‘BeforeSoftwareInstall’ 
        } 
        LocalConfigurationManager 
        { 
            RebootNodeIfNeeded = 'False' 
        }  
    }   
}