Validate PowerShell DSC Node Status

Michael Greene

This is part of a blog series first referenced here: Validate the new features of PowerShell DSC

New Capability

A new cmdlet is available named Get-DscConfigurationStatus. This cmdlet returns detailed information about the status of a node.

What is the purpose of this feature?

Customers have told us that they need to be able to get more information about the state of a machine that is managed using DSC. In response, we have introduced a new cmdlet that is meant to begin addressing the issue.

What is the easiest way to test it?

You can run just the cmdlet with no special settings for basic information, or you can pipe the output to cmdlets such as Format-List followed by an asterisk to reveal all of the information available about the status of the machine.

 

Example 1

 

Configuration TextFile    {        Import-DscResource -ModuleName 'PSDesiredStateConfiguration'                File TestFile        {            DestinationPath = 'C:\\TextFile\\test.txt'            Contents = 'This is some text'        }    }    TextFile -out c:\\TextFile    Start-DSCConfiguration -path c:\\TextFile -verbose -wait

 

You can also get a detailed history of how the machine has been configured in the past, if over time more than one configuration was applied (each new configuration replaces the last).

 

Example 2

 

    Get-DscConfigurationStatus -All

 

What should I expect to see?

 

For the first example above, you should see detailed status including metadata about the machine (network information, hostname, LCM version) and details about both the configuration and the status of each individual resource that is used within the configuration.

Output 1

DurationInSeconds          : 0    Error                      :     HostName                   : HOSTNAME    IPV4Addresses              : {169.254.54.116}    IPV6Addresses              : {fe80::a473:b41d:42e5:3674%40}    JobID                      : {BC93992D-1B66-11E5-807A-000B56D158CE}    LCMVersion                 : 2.0    Locale                     : en-US    MACAddresses               : {84-3A-4B-47-82-F4}    MetaConfiguration          : MSFT_DSCMetaConfiguration    MetaData                   : Author: you; Name: TextFile; Version: 2.0.0;                                  GenerationDate: 06/25/2015 13:17:37;                                  GenerationHost: HOSTNAME;    Mode                       : PUSH    NumberOfResources          : 1    RebootRequested            : False    ResourcesInDesiredState    : {[File]TestFile}    ResourcesNotInDesiredState :     StartDate                  : 6/25/2015 1:19:37 PM    Status                     : Success    Type                       : Consistency    PSComputerName             :     CimClass                   : root/Microsoft/Windows/DesiredStateConfiguration:M                                 SFT_DSCConfigurationStatus    CimInstanceProperties      : {DurationInSeconds, Error, HostName,                                  IPV4Addresses...}    CimSystemProperties        : Microsoft.Management.Infrastructure.CimSystemPrope                                 rties

 

 

For the second example, you should see a table with details of each configuration that has ever been applied to the machine. You could also set this output to a new variable and then dig into details of any one of the individual past status items.

 

Output 2

 

Status     StartDate                 Type            Mode  RebootRequested         ------     ---------                 ----            ----  ---------------         Success    6/25/2015 1:04:37 PM      Consistency     PUSH  False                   Success    6/25/2015 12:51:11 PM     Initial         PUSH  False                   Success    6/25/2015 12:49:37 PM     Consistency     PUSH  False                   Success    6/25/2015 12:37:18 PM     Initial         PUSH  False                   Success    6/25/2015 12:34:37 PM     Consistency     PUSH  False                   Success    6/25/2015 12:19:37 PM     Consistency     PUSH
False                   Success    6/25/2015 12:19:01 PM     Initial         PUSH  False

 

 

Can you help me set up my lab machine?

 

You will need to have applied at least one configuration to your test machine. If you have never used DSC before, the following example creates a simple configuration that writes a text file. You can apply this configuration to your test machine by opening PowerShell ISE as administrator, copying in this snippet, and running it. You can expect to see output that indicates the configuration was applied successfully. At that point, you can expirement with Get-DscConfigurationStatus using the examples above.

Configuration TextFile    {        Import-DscResource -ModuleName 'PSDesiredStateConfiguration'                File TestFile        {            DestinationPath = 'C:\\TextFile\\test.txt'            Contents = 'This is some text'        }    }    TextFile -out c:\\TextFile    Start-DSCConfiguration -path c:\\TextFile -verbose -wait

 

 

How to provide feedback

 

The first post in this series intro post, contains 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.

 

Suggestions for additional examples are welcome as comments. Thank you!

 

Michael Greene Senior Program Manager ECG CAT Team; PowerShell & Automation

 

0 comments

Discussion is closed.

Feedback usabilla icon