具有复合密钥的自定义powershell DSC资源
为了论证,我有两个实体,我们称它们为实体a和实体b,两者之间可以有1:M的关系。我要做的是创建一个powershell dsc资源,将两者链接在一起,以便执行以下操作:具有复合密钥的自定义powershell DSC资源,powershell,dsc,Powershell,Dsc,为了论证,我有两个实体,我们称它们为实体a和实体b,两者之间可以有1:M的关系。我要做的是创建一个powershell dsc资源,将两者链接在一起,以便执行以下操作: MyResource link { EntityA = "entity a" EntityB = "entity b" Ensure = "Present" } 两个问题: [DscProperty(Key)]是否可能是两个值的组合 通过DSC是否有更优雅的解决方案 对于由多个属性组成的密钥,每个属性
MyResource link
{
EntityA = "entity a"
EntityB = "entity b"
Ensure = "Present"
}
两个问题:
对于由多个属性组成的密钥,每个属性都需要自己的dsc属性,例如,对于密钥由KeyPart1和KeyPart2组成的资源,如下所示:
[DscProperty(Key)]
[string]$KeyPart1
<#
Specifies the volume to be added to / removed from the pod.
#>
[DscProperty(Key)]
[string]$KeyPart2
[DscProperty(键)]
[字符串]$KeyPart1
[DSC属性(密钥)]
[string]$KeyPart2