I\'m working on a DSC composite resource, but I can\'t seem to get it working. My code:
E:\\Dev\\DSCResources\\run.ps1:
Import-Modul
After your update I could successfully reproduce your problem, after which I couldn't get my original configuration working again, making me believe I made some kind of error in my original test. In the following examples, I will use BaseConfig
for config name and MyParameter
for parameter name.
In order to create a longer description with line-by-line instructions, I wrote a blog post on the subject: http://robertwesterlund.net/post/2014/03/12/creating-a-composite-dsc-configuration-with-parameters
When a Composite Configuration is created as an ordinary module (directly in the C:\Program Files\WindowsPowerShell\Modules\MyModuleName
, for example), it seems like it behaves like an ordinary Cmdlet. This means, to pass parameters to the composite configuration I had to do:
Import-DscResource -ModuleName BaseConfig
Node localhost
{
BaseConfig Common -MyParameter "My Parameter Value"
{
}
}
I must admit that I don't know if this would behave as expected for a DSC resource for other parts.
The way I wanted to write the configuration was the following:
Import-DscResource -Name BaseConfig
Node localhost
{
BaseConfig Common
{
MyParameter = "My Parameter Value"
}
}
(Notice that the Import-DscResource
also differs.)
To get this working, I had to make a dummy container module (which, of course, could contain implementation if necessary, but I only created an empty psm1
file and a psd1
file pointing to that psm1 file. After making the container module without implementation, I then made a DSC Resource module (located in the MyContainerModule\DSCResources\MyCompositeConfiguration
folder) for the composite configuration. After this it worked just as expected. This is probably the correct way to create a composite configuration.