Nesting PowerShell DSC configurations from different files

If you want to reference a configuration from another configuration that is not defined in the same file, you need to use the composite resource pattern.

In a module, you'll create a DscResources folder. In that folder, you'll create a module to hold your composite configurations. The composite configuration will be defined in a file with the extension .schema.psm1. The file will require a module manifest pointing to the schema.psm1 file as the root module.

For more detail and an example, check out the PowerShell team blog - http://blogs.msdn.com/b/powershell/archive/2014/02/25/reusing-existing-configuration-scripts-in-powershell-desired-state-configuration.aspx


Splatting the parameters helps - following amended Primary.ps1 should work:

. .\Secondary.ps1

Configuration MyConfiguration {
    Node localhost {
        $params = @{ SomeParameter = "TestEnvVar" }
        Secondary TheSecondary @params
    }
}

MyConfiguration

Start-DscConfiguration .\MyConfiguration -Wait -Verbose

Tags:

Powershell

Dsc