Injecting PowerShell DSC Meta and Node ConfigurationsPublished on 07 Dec 2014
Tags #Desired State Configuration#DSC#LCM#PowerShell#PSDSC
In large environments, you will need to automate the meta configuration necessary to kick off the local configuration manager. Microsoft has published a lengthy article about injecting a meta as well as a node configuration into VMs and VHDs. I will present a such easier method fully integrated and supported by the LCM. This article only describes which location can be used to inject MOFs.
There are two objectives to injecting a configuration into a VM or a VHD. First, the LCM requires a meta configuration because there are some switches you will want to tweak. Second, if you are using push mode, you need to provide the LCM with the node configuration.
Injecting the LCM Meta Configuration
When you place a MOF file in
C:\Windows\System32\Configuration\metaconfig.mof, the LCM will pick it up almost immediately and reconfigure itself.
Warning: The above does not suffice to configure the LCM because the scheduled tasks are not created. See my post about DSC and scheduled tasks.
Note that the MOF file must only contains the
MSFT_DSCMetaConfiguration and the
MSFT_KeyValuePair sections. You MOF file will almost certainly contain a
OMI_ConfigurationDocument section which is not supported in the meta configuration and must be removed manually or by my sample code.
Injecting the Node Configuration
After the LCM has been configured to suite your needs, the node configuration can be dropped into C:\Windows\System32\Configuration\Pending.mof which will be processed at the next configuration check (boot, service restart, forced check, internal).
Obviously, the MOF file may not contain a meta configuration.
Update: In contrast to placing a file in the right place, you can also make sure remotely that a configuration is applied. See my post how to remotely prepare a newly created VM.