How To Write A Simple Desired State Configuration (DSC) Configuration

DSC can be a complex topic but it doesn’t have to be. In this video, Matt shows us that we can install a Windows feature and create an HTML file to bring up an IIS web server from scratch using DSC.

In this video let's go over how to write a simple DSC configuration. In this configuration we're going to configure the node server, one as a Web Server. To do this we're going to use the windows feature. DSC resource to ensure that the Web Server feature is installed. If we hover over this red line. We can see that the windows feature resource requires a property called name so let's start there. One of the nice things about this is that you can use tab complete on most of the properties. So for name we're going to specify. The Web server. Feature. And we are also going to ensure. That, it is present. Next let's create a new HTML file which we can use on the new web server. If we hover over the red line, we can see that the file resource requires a destination path. For the destination path, we're going to use an HTML file under the WWW root folder on the server. Next let's set the contents of that file. To Hello World, Now let's set the type. To file And we're also going to ensure. That this is present. Next we want to make sure that this doesn't run until the Web Server feature has been installed to do that. We're going to use the depends on property. To specify that the windows feature? Web server property. Needs to run before this one will. Once that configuration is complete. We're going to run the configuration and pass it in output path of C Configs that is where it's going to store the MOF file which is going to be used to configure the server. Once we have them New MOF file. We're going to run start DSC configuration and wait for that to complete. So let's go ahead and run this configuration. Now let the configuration is complete. Let's go to Internet Explorer and browse to the new file that we created. As you can see we have our hello world, HTML file running on server one displaying hello world. Now just to show you that I'm not playing any tricks? Let's go into our configuration again and change the contents too. I love DSC. And run the configuration again. Now that that's complete if we go back to Internet Explorer and hit refresh. You can see that the contents of the file have been updated. That is how to write a simple DSC configuration. Keep an eye out for more of my videos covering other DSC topics such as creating more advanced DSC configurations and setting up nodes for push and pull scenarios.