Search code examples
powershelldsc

Powershell DSC, Output MOF to different folder


Given this simple configuration file:

Configuration MyDscConfiguration {

    Node "TEST-PC1" {
        WindowsFeature MyFeatureInstance {
            Ensure = "Present"
            Name =  "RSAT"
        }
        WindowsFeature My2ndFeatureInstance {
            Ensure = "Present"
            Name = "Bitlocker"
        }
    }
}
MyDscConfiguration

When run, the MOF file generated for Node "TEST-PC1", will be placed in a sub-directory named, MyDscConfiguration.

I am looking for a way to output the MOF to a custom directory location, e.g. mofs\MyDscConfiguration\

Is this possible?


Solution

  • Yes, your configuration has an -OutputPath parameter you can give it.

    Configurations are, essentially, functions and work mostly the same way.

    You can even use Get-Help MyDscConfiguration to see all the parameters it has (you can define your own param() block with it too, just like you would for a function).

    TAB completion works too, so that's a quick way to discover the params.