{"id":1051,"date":"2015-07-07T06:00:00","date_gmt":"2015-07-07T14:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/powershell\/2015\/07\/07\/validate-powershell-dsc-node-status\/"},"modified":"2021-09-15T12:14:59","modified_gmt":"2021-09-15T20:14:59","slug":"validate-powershell-dsc-node-status","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/validate-powershell-dsc-node-status\/","title":{"rendered":"Validate PowerShell DSC Node Status"},"content":{"rendered":"<div class=\"markdown-body\">\n<p>This is part of a blog series first referenced here: <a href=\"http:\/\/blogs.msdn.com\/b\/powershell\/archive\/2015\/07\/06\/validate-features-of-powershell-dsc.aspx\">Validate the new features of PowerShell DSC<\/a><\/p>\n<h2>New Capability<\/h2>\n<p>A new cmdlet is available named <strong>Get-DscConfigurationStatus<\/strong>. This cmdlet returns detailed information about the status of a node.<\/p>\n<h2>What is the purpose of this feature?<\/h2>\n<p>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.<\/p>\n<h2>What is the easiest way to test it?<\/h2>\n<p>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.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Example 1<\/strong><\/p>\n<p>&nbsp;<\/p>\n<div class=\"highlight highlight-powershell\">\n<pre class=\"lang:default decode:true\">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<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<p>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).<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Example 2<\/strong><\/p>\n<p>&nbsp;<\/p>\n<div class=\"highlight highlight-powershell\">\n<pre class=\"lang:default decode:true\">    Get-DscConfigurationStatus -All<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<h2>What should I expect to see?<\/h2>\n<p>&nbsp;<\/p>\n<p>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.<\/p>\n<p><strong>Output 1<\/strong><\/p>\n<pre><code><\/code><\/pre>\n<pre class=\"lang:default decode:true \">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<\/pre>\n<pre><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>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.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Output 2<\/strong><\/p>\n<p>&nbsp;<\/p>\n<pre><code><\/code><\/pre>\n<pre class=\"lang:default decode:true \">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\r\nFalse                   Success    6\/25\/2015 12:19:01 PM     Initial         PUSH  False<\/pre>\n<pre><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre><code><\/code><\/pre>\n<p>&nbsp;<\/p>\n<h2>Can you help me set up my lab machine?<\/h2>\n<p>&nbsp;<\/p>\n<p>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 <strong>Get-DscConfigurationStatus<\/strong> using the examples above.<\/p>\n<div class=\"highlight highlight-powershell\">\n<pre class=\"lang:default decode:true \">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<\/pre>\n<p>&nbsp;<\/p>\n<\/div>\n<p>&nbsp;<\/p>\n<h2>How to provide feedback<\/h2>\n<p>&nbsp;<\/p>\n<p>The first post in this series <a href=\"http:\/\/blogs.msdn.com\/b\/powershell\/archive\/2015\/07\/06\/validate-features-of-powershell-dsc.aspx\">intro post<\/a>, contains a summary of options for providing feedback. The best option is to use <a href=\"https:\/\/connect.microsoft.com\/PowerShell\">Microsoft Connect<\/a>. Thank you so much for your time! It is sincerely appreciated.<\/p>\n<p>&nbsp;<\/p>\n<p>Suggestions for additional examples are welcome as comments. Thank you!<\/p>\n<p>&nbsp;<\/p>\n<p>Michael Greene\nSenior Program Manager\nECG CAT Team; PowerShell &amp; Automation<\/p>\n<p>&nbsp;<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":658,"featured_media":13641,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[150,162,248],"class_list":["post-1051","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell","tag-dsc","tag-feedback","tag-powershell"],"acf":[],"blog_post_summary":"<p>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 [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/1051","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/users\/658"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/comments?post=1051"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/1051\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media\/13641"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media?parent=1051"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=1051"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=1051"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}