Wednesday, 28 August 2013

How to explode a Dictionary List as headers in a format-table

How to explode a Dictionary List as headers in a format-table

Sorry for the title, not sure how to label this question. I want to
express a list of Dictionary objects with Key as Header/Property and Value
as the header/property value.
For example take the following PoSH code
$obj1 = new-object object | select Data; $obj1.Data =
@{"header1"="Value1";"header2"="Value2";}
$obj2 = new-object object | select Data; $obj2.Data =
@{"header1"="ValueA";"header2"="ValueB";}
$tmp = @($obj1,$obj2)
$tmp then looks like the following:
Data
----
{header2, header1}
{header2, header1}
$tmp | select -Expand Data gets the following useful information
Name Value
---- -----
header2 Value2
header1 Value1
header2 ValueB
header1 ValueA
Anyway I can pivot the data and turn the Names into Properties (or
headers) and express them with values i.e.
header1 header2
---- -----
Value1 ValueB
ValueA Value2

No comments:

Post a Comment