28 Days of DSC: Day 3 Basic Troubleshooting – Job Logs4 min read

Hey Guys,

Back again for another 28 Days of DSC post. I’m still refining the order in which I want to post these out. Later on next week I think posts will start coming in for developing custom resources, so look forward to that. For now, lets concentrate on confirming that what we currently have, is working how it should.

There are various different methods of getting access to the DSC job logs, through the Windows Event Log, direct from the log file on disk, using the xDscDiagnostics PowerShell module or from the DSC Compliance Server.

For the SCOM enthusiasts among you, here is cool blog post by Bruno Saille @ Microsoft about how dsc nodes can be discovered and monitored with a custom MP.

 
 

Again, since I don’t want to just type up everything if it’s already been done, head over to docs.microsoft.com for a good set of instructions on how to troubleshoot using the Event Log and the xDscDiagnostics Resource.

However, there are a few ways we can automate some of the steps they have documented and what is if the Event Logs haven’t been activated and the xDscDiagnostics module isn’t available?

Enabling Event Logs using xDscDiagnostics

Enabling the Event Logs with the xDscDiagnostics module is as easy 1,2,3

Unfortunately there isn’t a DSC Resource for this right now but maybe we can create that in a later post.

Get-DSCConfigurationStatus command

Using Get-DSCConfigurationStatus returns a summary of the last job’s details. Using -All returns then all the logs available.

The useful properties in this output are ResourcesInDesiredState, ResourcesNotInDesiredState, Success, Error.

The ResourcesIn and NotInDesiredState object look like this. In this particular case we can see that the error is a json object and occurred because the Registry Key I was trying to set didn’t exist.

To get just the error in a nice PowerShell format, use ConvertFrom-Json.
$ResourceNotInDesiredState.Error | ConvertFrom-Json

 
 

New-xDscDiagnosticsZip

A useful command when working with colleagues to resolve DSC Problems is to send them the logs so that they may analyse and get back to you.

New-xDscDiagnosticsZip pulls information from all the available sources and nicely prepares it to send to friend :).

File Based Log Access

In the worst case scenario when none of the previous options are available the disk is still your friend. Every DSC job is written into C:\Windows\System32\Configuration\ConfigurationStatus.

Exactly what would be written to the console, is what will be written to these files i.e. if -Verbose was not given when Start or Update-DSCConfiguration was run, then the verbose output will not be seen in these files.

As with the New-xDscDiagnosticsZip command, these file could be zipped and sent to someone else to assist with troubleshooting.
 
 
 
 
Hope this is useful for you and can help reduce the time it takes to resolve problems in your DSC Configurations.

Make sure to come back because later in the month, coming up in the series we still have nested configurations, composite resources, script and class based resources, partial configurations and much much more.

I look forward to hearing from you either in the comments or on Twitter with the #DFTAI or #28DaysOfDSC

Thanks & Don’t Forget To Automate It!

Leave your comment