PowerShell Desired State Configuration (DSC) Journey – Day 12

Today I am going to do some work with the Log Resource.  The TechNet Article for Resource is pretty straightforward.  I have been thinking about how I would use this for a day now, and I really haven’t come up with anything useful because as I covered here the DSC Diagnostics Module provides some really good logging.  I feel like this is a Resource that was built for the future (and maybe it works better for Custom Resources??) than for using the out of box ones.  Nevertheless, let’s do some logging!

First thing to note is that the Log Message will appear in the Microsoft-Windows-Desired State Configuration/Analytic Event Log.  There are only 2 Properties, Message and Depends on.  Pretty straightforward.  Let’s add a couple of Logs to the Configuration I have been using and see what happens.  Here are the lines that I added.

I intentionally used Parameter names in the Message blocks to see if it actually uses them.  It looks like it should work in the ISE Editor, so lets find out.  I Invoke the Configuration, send it to the Pull Server, and force DSCTest to pull its Configuration.

While doing this, I noticed that for the second day in a row the Consistency scheduled task on DSCTest had been running non stop since 2:38AM this morning.  Yesterday I rebooted the server and it fixed the problem.  Today I ended the task and set it to kill itself if it ran for more than an hour.  It was set to 3 days by default, which I don’t agree with at all.  I start the scheduled task again and it just runs and never does anything.  Typically it runs for about 15 seconds and then it’s done.  It’s scheduled to run on it’s own in 3 minutes so I will just wait for that and see what happens.  It started, but then it doesn’t stop.  It had been running for a good 5 minutes now before I end it.

I also tried doing it the way Don Jones suggested in the comments to this post.

And I just got this error message for my trouble.

Which doesn’t make any sense because I am using PowerShell as a Domain Admin and I have rights to do everything else I have ever needed to do.  Time for the magical reboot server trick!

After the reboot the DSCRestartBootTask ran successfully and I was able to get this information.

Which is interesting.  So then let’s do this.  I have shortened the output to show the interesting parts.

It appears to be failing because of this.

I never checked back yesterday after BGInfo got installed but it clearly doesn’t like the fact that it can’t verify the ProductID.  So, let’s try something here.  Also I should note at this point that none of my messages got logged because the Configuration failed.

I set the BGInfoInstall Package Resources to Absent and try again. No dice.  Same errors.  Well.  Crap.  Clearly I will need to do some playing around with this.  For the sake of testing the Log Resource I remove those entries from my Configuration and try it again.  And it works.  Let’s check out the log file.

There are a lot of entries like the one below, but none with my actual message.  So let me try changing one to not include a parameter name.

The Trace of the DSCOperation has entries like this, but again, none with my message in them.

I changed my Log Success to this, and then Invoked the Configuration again.

In doing this, I must have been blind previously because it did log what I had in there.  Here are some examples of what it looks like.

That’s all I have time for today , but I am seeing a lot of inconsistencies in the logging.  I ran the exact Configuration again, and the only thing it logged was the Log ScriptFolder Resource, there were no entries for Log Success or Log DNSServerAddress.