I'm currently trying to automate the build of a VM running Windows Server 2012 R2. At the moment the challenge is automating the addition of roles and features. Within the roles and features wizard there is an option to export an XML configuration file which can be run in PowerShell.
However, after looking through the XML file I can see it it is specific to the server it is running on – it contains fields such as "ComputerName".
What if I want to run a script which installs roles and features on many VMs? I need a configuration file which is generalized, not personalized to a specific computer.
Does anyone have an input on this issue?
Best Answer
Yes, for both Linux and Windows you can build desired state config files that can:
Here is a sample config file that will enable IIS, ensure that the website files are in the right folder, and if any of these things are not installed or missing, to install or copy them as appropriate (note that $websitefilepath is presumed to be predefined as the source for the website files):
For more details see Windows PowerShell Desired State Configuration Overview and Get Started with Windows PowerShell Desired State Configuration.
So why would you use this instead of simply the install-windowsfeature cmdlet? The real power of using DSC instead of a script is that I can define a location where I can store configurations to be pushed to or pulled from (with respect to the target machine) see Push and Pull Configuration Modes. The configuration doesn't care if the machine is physical or virtual, but I believe it takes at least 2012 to get the server to boot to pull DSC.