Populating your CMDB with DSC Configuration Items Using SMA – Part 3

Author by Duncan Lindquist

Creating the SMA Runbooks and Monitor

Now that our classes are ready ant the Service Request has been built we are ready to build our SMA runbooks! All of these scripts are posted on the technet gallery you will find the link at the end of the post.

The first Script that we will need to create is the monitor. To create the monitor we can follow the steps in this blog post. The monitor runbook will look like this:

DSC10-548x1024.png

Now lets look through the monitor to see what we are doing.  The first to steps to get the runbooks and get the service request are covered in this blog post.

The next step is to get the related computers name and the Config Type.

DSC11.png

To get the related computer you need to take the following steps using powershell:

1. Get the Service Request class then us the class to get the Service Request object.

2. Get the Configuration items that are related to the Serivce Reqest.

3. Get the related computer item.

DSC12-1024x345.png

To get the Configuration Type we will use the same powershell except instead of getting the related computer we will get the custom class that you created for the Configuration type.

DSC13.png

Next we need to create the mof file for the configuration that we want to set. We do this by kicking of the DSC-CreateMOF passing it the Configuration Type and the Server.

DSC14.png

DSC-CreateMOF is actually just a script with a switch that kicks of the proper MOF creation based of the configuration type that is input.

DSC15.png

The $GUID variable is being set by the config runbooks. These runbooks create a DSC Configuration. They then use the Configuration to create a mof file for the server we want to deploy the configuration to. Once the MOF file is created it is assigned a guid for the name and moved to the pull server.

DSC16.png

Now that we have the mof file created and on the pull server it is time to configure the pull.

DSC17.png

To do this we first need to configure the settings for the pull. This is done in the configuration setting bellow. The next step is to enable the pull.

DSC18.png

Not that the pull is configured it is time to create the DSC config ID in SCSM and relate the computer and DSC Type.

DSC19.png

To do this we need to first get all the classes and relationships we want to create and store them to variables. We can then use those variables to create the configuration ID object and its related items.

DSC20-1024x550.png

Now that the items and relationships are created the last step is to complete the Runbook Automation Activity.

DSC21.png

To complete the runbook we can run the following script. This will get the runbook activity and set its status and SMA runbooks status to Complete.

DSC22.png

Now our service request is complete and our DSC configuration has been deployed!

Link to download all of the scripts: https://gallery.technet.microsoft.com/scriptcenter/Deploying-and-DSC-35e4a7ec#content

Links to the blogs posts in this series:

Author

Duncan Lindquist

Service Management & Automation Solution Lead