Get-VM -Name vm-* | Group-Object -Property {$_.CustomFields['deployment']} | where {$_.Name -like 'service-instance_*'} | fl
Name : service-instance_9c854520-8e43-4566-845e-111e6a1e8425
Count : 6
Group : {vm-785dd36f-d984-4700-9b8d-54381758d141, vm-46e24f81-d4ad-4722-9cc3-1c70b631663d, vm-14876478-6e6e-4a00-933f-7bafecbef991, vm-bcc0550b-5203-48f0-a674-d59543ddb5e0...}
Values : {service-instance_9c854520-8e43-4566-845e-111e6a1e8425}
and
Get-VM -Name vm-* | Group-Object -Property {$_.CustomFields['deployment']} | where {$_.Name -like 'service-instance_*'} |
ForEach-Object -Process {
Group-Object -InputObject $_.Group -Property {$_.CustomFields['job']} | fl
}
Name :
Count : 1
Group : {vm-785dd36f-d984-4700-9b8d-54381758d141 vm-46e24f81-d4ad-4722-9cc3-1c70b631663d vm-14876478-6e6e-4a00-933f-7bafecbef991 vm-bcc0550b-5203-48f0-a674-d59543ddb5e0 vm-063992a7-c9f3-4cee-9287-27e4a4ac15b1 vm-73d25407-4e22-4e70-a2af-825b33ede569}
Values : {$null}
Sorry I didn't provide this earlier. Was being hurried to dinner Boarding a flight in a few hours so may get time to play around some more with the second grouping to figure out why it's not picking that Name up.