简体   繁体   中英

custom powershell DSC resources with composite keys

I have two entities for the sake of argument lets call them entity a and entity b, there can be a 1:M relationship between the two. What I want to do is to create a powershell dsc resource that links the two together, so that I can perform:

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

Two questions:

  1. Is it possible for the [DscProperty(Key)] to be a composite of two values ?
  2. Is there a more elegant solution to this problem via DSC

It appears that in the case of a key that consists of more than one attribute, each attribute requires its own dsc property, for example, for a resource with a key composed of KeyPart1 and KeyPart2, this looks like:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM