PowerShell Desired State Configuration (DSC) Journey – Day 10

Yesterday I talked about troubleshooting what was wrong with DSCTest server being unable to pull the module file from the Pull Server.  After a couple of breaks and some reading I figured it out (the answer is at the end of the article), and everything is working great.

Today, I am going to back to the File resource that I started with originally.  As part of our server builds we put BGInfo on all the servers, and we have a .bat file that runs that configures the way we want it.  So I am going to add to my Server Config Configuration (with an eye towards using this is as a composite resource not too far down the line) to copy these files, and then use the Package resource to install it.  Hopefully.  One other thing that I should mention is that I went ahead and downloaded all of the community DSC resources from here and going forward will be using them instead of the Microsoft provided ones.

First, I need to do two things. I want to ensure that the C:\Scripts folder always exists.  Once I know that exists, I want to copy the BGInfo folder and files into that location.  Here is the code that I added into my Configuration to do this.

Nothing fancy there.  Now to test this, I need to make sure I use the same GUID that I used before when I told DSCTest which configuration to look to pull from the Pull Server.  To get this I just browse to \\PullServer\C$\Program Files\WindowsPowerShell\DSCService\Configuration, get the GUID and set $guid = GUID in PowerShell.  I Invoke the Configuration to generate the .MOF file.  I then push that .MOF file out to the PullServer.  Since it has the same GUID as before, and DSCTest knows to look for that GUID, it should automatically pick it up.  I verified it’s the right GUID by entering into a PSSession on DSCTest and running Get-DSCLocalConfigurationManager.  The ConfigurationID should match the GUID, and mine does.

And this doesn’t work.  It pulls the Configuration fine, but it says that DSCTest is in compliance and everything is fine.  I went through a lot of troubleshooting steps, double and triple checking things before I figured out what the problem was.  It’s wonderful and all that you keep the GUID the same, but if you don’t generate a new checksum it won’t matter.  Lesson learned.  Once I did that it created the file.

Now that I have ensured my Scripts folder will be present, I need to copy my BGInfo folder and files into it.  To do that I have the code below.

I Invoke the Configuration, Copy the file to the PullServer, GENERATE A NEW CHECKSUM(!!!) and run the scheduled task on DSCTest.  BAM!



Lesson(s) Learned:  Even if the GUI is the same, if you update the Configuration and generate a new .MOF you need to generate a new Checksum. This can be done by using the command New-DSCChecksum -Force -Destination $dest.

Tomorrow:  I try to use the Package resource to install BGInfo.

If you are curious here is the full log of the implementation of the Configuration.  Warning.  This is long.