If I nest DSC configurations in a single file like this, it works fine:
Configuration Secondary { Param ($SomeParameter) Environment Test { Name = $SomeParameter Value = "12345" } } Configuration MyConfiguration { Node localhost { Secondary TheSecondary { SomeParameter = "TestEnvVar" } } } MyConfiguration Start-DscConfiguration .\MyConfiguration -Wait -Verbose I want to split my configuration in to two separate files. One will dot-source the other to include the configuration.
Secondary.ps1:
Configuration Secondary { Param ($SomeParameter) Environment Test { Name = $SomeParameter Value = "12345" } } Primary.ps1:
. .\Secondary.ps1 Configuration MyConfiguration { Node localhost { Secondary TheSecondary { SomeParameter = "TestEnvVar" } } } MyConfiguration Start-DscConfiguration .\MyConfiguration -Wait -Verbose For some reason this doesn't pick up the parameter passed in to the secondary configuration and so results in the error:
Could not find mandatory property Name. Add this property and try again. + CategoryInfo : ObjectNotFound: (root/Microsoft/...gurationManager:String) [], CimException + FullyQualifiedErrorId : MI RESULT 6 + PSComputerName : localhost It seems very strange that it works when in the same file but not when dot-sourcing. I thought that dot-sourcing was basically the same as including code in the same file. What am I missing here?
. "c:\full\path\to\Secondary.ps1"?