Jef*_*eff 2 powershell dsc powershell-5.0
在DSC中,我如何创建自定义模块(PowerShell 5 DSC类或MOF +脚本)并表示它需要/依赖于另一个DSC资源(如PowerShell Gallery中的xBlah).
在chef中,我可以将这些依赖项放在metadata.rb文件中以表达inter-cookbook依赖项.有没有办法在DSC中表达资源间的依赖关系?
您需要在自定义资源中实现DependsOn关键字.然后,您可以在配置中使用它来定义依赖项.一般格式是:
DependsOn = "[DSC Resource type] Name of the block"
Run Code Online (Sandbox Code Playgroud)
您甚至可以将多个依赖项指定为数组,如下面的示例所示:
DependsOn = @(“[WindowsFeature]HyperV”,
“[File]VHDFolder”)
Run Code Online (Sandbox Code Playgroud)
用法参考: 在PowerShell中的"所需状态配置"脚本中配置依赖项
另一个更贴切的参考: DSC 201 - 自定义操作