Creating a DSC Configuration Template

During the recent TechEd in Houston, there was a lot of talk and excitement about Desired State Configuration, or DSC. I’m not going to cover DSC itself here but rather address a minor issue for those of you just getting started. When you build a configuration, how can your figure out what resource settings to use?

To start with, you can look use the Get-DSCResource cmdlet which will list all resources in the default locations.


The properties for each resource are also there, although you have to dig a little.


From the screen shot you can see which properties are mandatory and the possible values for the rest. The Get-DSCResource cmdlet will even take this a step further and show you the complete syntax on how to use a particular resource.


To build a configuration, you can copy, paste and edit. But I wanted more, as I often do when it comes to things PowerShell. So I wrote a function called New-DSCConfigurationTemplate that will generate a complete configuration with as many resources as you have available.

The function will create a configuration template with whatever resources you specify.
By default the function writes to the pipeline, but you can specify a file name and even open the file in the ISE. Here’s how to create a single template for all DSC resources on your computer.

Mandatory properties are preceded by a *, which you need to delete. Properties have all of the possible values or at the very least what type of value you need to enter. Simply delete what you don’t want and in no time you have a complete DSC configuration! Don’t forget to substitute a name in for without the <>.

I wrote this with the assumption that I could run this once to create a template, then copy and paste what I need into a new configuration. Another option would be to create ISE snippets for these resources.

Personally, anything that saves me typing is a great help. I hope you’ll let me know what you think.

Configure Local User Account with DSC

talkbubble Yesterday I posted an article on how to use PowerShell and the [ADSI] type accelerator to set a local user account. However, if you are running PowerShell 4.0 you have another option: Desired State Configuration (DSC).

I’m going to assume you have some basic understanding of how DSC works. If not, head over to the Public OneDrive folder for and grab a copy of the free DSC ebook.

DSC ships with a provider resource for user accounts.


Because of the account password, the official stance is to use a certificate to handle encrypting the password. You can read about that on the PowerShell team blog. But that’s more than I want to deal with right now, plus I trust the security of my local test network so my configurations will store the passwords as plain text in the resulting MOFs. I suppose I should show you the script I came up with.

This script is intended to define a set of MOFs for computers in my Globomantics domain that all start with “CHI”. The script takes an array of computernames. From there it defines the configuration, defines the necessary configuration data to allow plain text passwords and then executes the configuration. The configuration also has a Group resource to add the account to the local Administrators group. Note the DependsOn setting in the group configuration. This ensures that the account will be set up before adding it to the group.

To create the configurations I run my script specifying the computer names.

PowerShell will prompt me for the credentials. When finished I am left with a MOF file for each computer under C:\Scripts\LocalUserAccounts, because I specified an output path. When I’m ready, I can push the configuration to the servers:

And that’s it! I can verify using the NET USER command in a remote session.


DSC promises to change the way IT Pros get their work done, and in a positive way!

PowerShell 4.0 A First Look

021913_2047_WordTest1.pngMy first look at PowerShell 4.0 is now online at A few interesting bits but with 3.0 still gaining traction I’m wondering how much people will actually adopt 4.0. It seems to me that some of the biggest features like Desired State Configuration will require Windows Server 2012 on the back end and it might be a while before that is widespread.

Read my article here: