Sunday, September 22, 2013

PowerShell DSC–Custom Resource for the Global Assembly Cache

Starting to realize the potential for Desired State Configuration, the new feature in PowerShell V4.  To get started I’ve been reading the material on TechNet:

Windows PowerShell Desired State Configuration Overview

For me, this changes the way I expect to do deployment automation.  Until now I’ve been mostly writing scripts to lay down configuration in FIM.  There have been some challenges with that approach, such as:

  • the deployment script is only really useful for a fresh deployment
  • the scripts are not usually reentrant, unless you do the work to make them so
  • the scripts do not usually prevent configuration drive of a running system
  • the scripts are, well, still code

DSC seems like an elegant solution to this, because it give the power of configuration declaratively, while still allowing me to write code for complex situations (you can bury this in Custom DSC Resources).  For moron Custom DSC Resources see:

Build Custom Windows PowerShell Desired State Configuration Resources

To learn more I decided to try a sample custom DSC resource to handle entries in the Windows Global Assembly Cache.  A FIM deployment always need to make sure the GAC is populated with the correct DLLs, so it made sense to start with this.  I followed the guidance on TechNet and was able to produce this custom resource in under an hour.  With that custom resource I can now declare the GAC items like this:

Sample DSC Script



Configuration FimServiceConfig


   ### Configuration for my FIM Service computer

   Node "MyFimBox"



    ### Make sure the FIM Service is running and set to Automatic

    Service FimService


        Name        = "FimService"

        StartupType = "Automatic"

        State       = "Running"



    ### Make sure the GAC has the PowerShell Workflow for FIM

    GlobalAssemblyCacheItem FimWorkflowLibrary


        Ensure       = "Present"

        Name         = "FimExtensions.FimActivityLibrary"

        Version      = ""

        AssemblyFile = "C:\tfs\Output\FimExtensions.FimActivityLibrary.dll"





I plan on sharing the sample custom resource on if they’ll have it.  They are trying to organize the custom modules so that they’re easier to find:

Need Desired State Configuration Modules?

Anyhow, with this little experiment mostly complete I’m really excited about doing the custom resources for FIM, then changing the way I do deployment automation to be largely declarative.  PowerShell is way too cool.

No comments: