Validate PowerShell DSC Partial Configurations

Michael Greene

This post is part three of a blog series introduced in Validate the new features of PowerShell DSC.


New Capability


DSC now has the ability to merge partial configurations into one configuration for management.


What is the purpose of this feature?

Customers have told us that in some cases, multiple teams contribute to a configuration. It can be organizationally challenging to manage a collective configuration. Customers want to be able to allow individual teams to author the portions of the configuration for which they are responsible, and then use the DSC Local Configuration Manager to merge the partial configurations and help to resolve conflicts among the partial configurations. That would help to reduce the administrative overhead for managing configurations, reduce the potential for errors, and allow teams to be flexible about making updates to the configuration on their own schedule. DSC now has that capability.

Other DSC features introduced in this series of blog posts will enable you to obtain detailed information about a node’s configuration, and to obtain a history of the configuration changes that were made to a node over time. These features combine to create powerful new capabilities for DSC configuration management and test automation.

What is the easiest way to test it?

You will need multiple configurations to demonstrate the new capability. Two example partial configurations and one example merge configuration are given below. Configuration RDP represents an operating system configuration. Configuration TextFile represents an application configuration. Configuration TestPartialConfigs specifies the two partial configurations to the Local Configuration Manager, which merges the partial configurations to establish the desired state configuration for the node.

First, add a module for configuring RDP. (You will need to respond \”Yes\” to accepting the module from the online gallery.)

 Install-Module xRemoteDesktopAdmin


Second, run a script to set up the Local Configuration Manager, generate configurations, and deploy. Note that the text file requires remote desktop administration to be turned on with user authentication set to Secure, using a \”DependsOn\” property. The RefreshMode is unique per Configuration so you can either use Push or Pull mode on a per-configuration basis.

 [DscLocalConfigurationManager()]\    Configuration TestPartialConfigs\    {\        PartialConfiguration RDP\        {\            Description = 'Enable RDP'\            RefreshMode = 'Push'\        }\\        PartialConfiguration TextFile\        {\            Description = 'Create a text file'\            RefreshMode = 'Push'\            DependsOn = '[PartialConfiguration]RDP'\        }\    }\    TestPartialConfigs -outputpath c:\\TestPartialConfigs\    Set-DscLocalConfigurationManager -Path c:\\TestPartialConfigs -Verbose\\    Configuration RDP\        {\            Import-DscResource -ModuleName 'PSDesiredStateConfiguration','xRemoteDesktopAdmin'\            xRemoteDesktopAdmin TestRDP\            {\                Ensure = 'Present'\                UserAuthentication = 'Secure'\            }\        }\    RDP -outputpath c:\\RDP\    Publish-DscConfiguration -path c:\\RDP -verbose\\    Configuration TextFile\n"); doc
ument.write("        {\            Import-DscResource -ModuleName 'PSDesiredStateConfiguration'            \            File TestFile\            {\                DestinationPath = 'C:\\TextFile\\test.txt'\                Contents = 'This is some text'\            }\        }\    TextFile -out c:\\TextFile\    Publish-DscConfiguration -path c:\\TextFile -verbose\\    Start-DscConfiguration -UseExisting


What should I expect to see?

Use Get-DscConfiguration and Get-DscConfigurationStatus to examine the configuration generated by the LCM. Example below.

 PS C:\\WINDOWS\\system32> (Get-DscConfigurationStatus).ResourcesInDesiredState\\\    ConfigurationName    : RDP\    DependsOn            : \    ModuleName           : xRemoteDesktopAdmin\    ModuleVersion        :\    PsDscRunAsCredential : \    ResourceId           : [xRemoteDesktopAdmin]TestRDP\    SourceInfo           : ::21::9::xRemoteDesktopAdmin\    DurationInSeconds    : 0.297\    Error                : \    FinalState           : \    InDesiredState       : True\    InitialState         : \    InstanceName         : TestRDP\    RebootRequested      : False\    ResourceName         : xRemoteDesktopAdmin\    StartDate            : 6/26/2015 5:02:02 PM\    PSComputerName       : \\    ConfigurationName    : TextFile\    DependsOn            : \    ModuleName           : PSDesiredStateConfiguration\    ModuleVersion        : 1.1\    PsDscRunAsCredential : \    ResourceId           : [File]TestFile\    SourceInfo           : ::33::9::File\    DurationInSeconds    : 0.328\    Error                : \    FinalState           : \    InDesiredState       : True\    InitialState         : \    InstanceName         : TestFile\    RebootRequested      : False\    ResourceName         : File\    StartDate            : 6/26/2015 5:02:02 PM\    PSComputerName       : \

How to provide feedback

The introductory post lists a summary of options for providing feedback. The best option is to use Microsoft Connect. Thank you so much for your time! It is sincerely appreciated.


Michael Greene


Discussion is closed.

Feedback usabilla icon