【问题标题】:custom powershell DSC resources with composite keys具有复合键的自定义 powershell DSC 资源
【发布时间】:2018-07-23 09:24:46
【问题描述】:

为了论证,我有两个实体,我们称它们为实体 a 和实体 b,两者之间可以有 1:M 的关系。我想做的是创建一个将两者链接在一起的powershell dsc资源,以便我可以执行:

MyResource link
{
    EntityA = "entity a"
    EntityB = "entity b"
    Ensure  = "Present"
}

两个问题:

  1. [DscProperty(Key)] 是否可以是两个值的组合?
  2. 有没有更优雅的方法通过 DSC 解决这个问题

【问题讨论】:

    标签: powershell dsc


    【解决方案1】:

    似乎在一个键包含多个属性的情况下,每个属性都需要自己的 dsc 属性,例如,对于具有由 KeyPart1 和 KeyPart2 组成的键的资源,这看起来像:

    [DscProperty(Key)]
    [string]$KeyPart1
    <#
        Specifies the volume to be added to / removed from the pod.
    #>
    [DscProperty(Key)]
    [string]$KeyPart2
    

    【讨论】:

      猜你喜欢
      • 2018-04-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多