Compiling DSC configurations using RegistrationKeys

When making the MOF files for DSC pull servers that use RegistrationKeys, you do not name the MOF file with the ConfigurationID of the target node, as there is no ConfigurationID assigned to the target node. Instead, the target node has the same RegistrationKey configured in its LCM that the DSC pull server has. This allows us to name the MOF files with descriptive human readable names as well as use DSC partial configurations.

The example code that follows is relatively naïve since it only handles the one MOF file we are compiling. In production, you would have this part of a release process where you compiled and renamed the MOF according to the naming scheme you chose. Here, we're using ExampleConfiguration, but the reason for the name is to name it with some relation to the purpose of the DSC configuration:

$outputPath = ([IO.Path]::Combine($PSScriptRoot, 'SetupTheSite'))
$dataScript = ([IO.Path]::Combine($PSScriptRoot, 'wmf5_config_data.ps1'))
$configData = &$dataScript
    
c:vagrantexample_configuration.ps1 -outputPath $outputPath -configData $configData | Out-Null
    
if(Test-Path (Join-Path $($outputPath) 'ExampleConfiguration.mof')){
  rm (Join-Path $($outputPath) 'ExampleConfiguration.mof')
}
Rename-Item -Path (Join-Path $($outputPath) 'dsc-box2.mof') -NewName 'ExampleConfiguration.mof'  

The result of running this script renames dsc-box2.mof to ExampleConfiguration.mof.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset