N
N
NewDevLab2020-06-13 14:41:45
PowerShell
NewDevLab, 2020-06-13 14:41:45

Combining objects?

How to adequately combine the properties of 2 objects into an array?
There is something like this code:

[psobject] $place1 = $Config1 |
    Select-Object -Property `
      @{label = "lbl"; 		expression = {$_.Custom.Property} }
  [psobject] $place2 = $Config2 |
    Select-Object -Property `
      @{label = "lbl"; 		expression = {$_.AnyProperty} }

those. the result should be a flat array, to which I will distink and get a unique array of values.
ConfigN is obtained from JSON.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
MaxKozlov, 2020-06-13
@NewDevLab

Well then, the simplest

$config1.Custom.Property, $config2.AnyProperty | sort-object -unique
#если без фильтрации чтобы сделать массив плоским вместо sort
...   foreach-object { $_ }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question