Extract features names from DeploymentConfigTemplate xml file

I am a lazy person. Trust me on this, it’s true.
So whenever I can find an easy way to accomplish a goal, I do it.
In this post I’ll show you how you can make use of Server Manager, export the configuration to a file and extract the information you need in deployment/configuration scripts from that file.


When I need to configure the roles of a server, let’s say ADDS/DNS/DHCP, I have a small and practical tip.
First, I click it. Yes, through a GUI. There are some roles in Windows Server that tend to include a whole bunch of sub-features… but not all of their sub-features.
When you go through the GUI, just before it will actually install, you’ll see the option to export the configuration settings.

This is exported to a XML file.
What I could do is use this file as input for a PowerShell script to install the desired features… but…. There is no such parameter on a cmdlet!

Next to that, I don’t like script dependencies on 2nd files.

So if we get the content of the XML file, we’ll want to filter out the feature names we need.
Getting the content of the XML file is pretty easy:

But that’s just the content of the file… we want specific values.
When you take a look at the content you’ll see we need the information defined as ‘ClassName’.
Though there are two pieces of information defined as ClassName: The feature name, and ‘MSFT_ServerManagerServerComponentDescriptor’.
So, let’s filter out what we need:

There are some leading spaces so let’s remove them with the Trim method. However, this method is only available for a string, so we first need to convert it to a string:

Almost there. We need to remove the crap that’s around the name of the feature:

One final tricky little thing. There are underscores in the name of the features while Windows works with dashes, not underscores.
So the final code:

Note that there is a more elegant way to accomplish: Use regex.
Since I needed just a quick fix, this was all I needed and had no real need to use regex.

Leave a Reply

Your email address will not be published. Required fields are marked *