Let's say that I have an Obj with data describing multiple entities. I want to output it like this (CSV, HTML, Format-Table, whatever):
Property Code Property descr. Entity1 Entity2 Entity3
abs_de234 abs prop for de 132 412 412
abs_fe234 abs prop for fe 423 432 234
... ... ... ... ...
I would use something like:
$ObjData | % {Select-Object @{Label = "Property Code"; Expression = {$_.propcode}}, @{Label = "Property Desc."; Expression = {$_.descr}}, @{Label = "Entity1"; Expression = {$_.entity1}}, @{Label = "Entity2"; Expression = {$_.entity2}},@{Label = "Entity3"; Expression = {$_.entity3}} }| Format-Table
But what if my object has variable number of entities? Let's say these properties are all in an array:
$EntityList = @('Entity1', 'Entity2', 'Entity4', 'Entity5', 'Entity5')
How, based on $EntityList
I can construct corresponding Select-Object
command?
Upd.: Based on Help for Select-Object
:
Select-Object
[-InputObject <PSObject>]
[[-Property] <Object[]>]
[-ExcludeProperty <String[]>]
[-ExpandProperty <String>]
[-Unique]
[-Last <Int32>]
[-First <Int32>]
[-Skip <Int32>]
[-Wait]
[<CommonParameters>]
Does this mean I should be able to just use Select-Object -Property $EntityList
?