DSC Custom Resource Dependencies

2019-07-10 10:59发布

In DSC how can I create a custom module (either PowerShell 5 DSC class or MOF + Script) and express that it requires/has a dependency on another DSC resource (like xBlah from PowerShell Gallery).

In chef, I can put such dependencies in my metadata.rb file to express inter-cookbook dependencies. Is there any way of expressing inter-resource dependencies in DSC?

1条回答
啃猪蹄的小仙女
2楼-- · 2019-07-10 11:56

You will need to implement DependsOn keyword in your custom resource. Then you can use this in your configuration to define dependencies. The general format is:

DependsOn = "[DSC Resource type] Name of the block"

You can even specify multiple dependencies as array as shown in the below example in a configuration:

DependsOn = @(“[WindowsFeature]HyperV”,
                      “[File]VHDFolder”)

Reference for usage: Configuring Dependencies in "Desired State Configuration" script in PowerShell

Another more apt reference: DSC 201 – Custom Actions

查看更多
登录 后发表回答