You know when you get some output from say Get-ExchangeServer that has load of values and when you output it to HTML it goes off the page and looks pants? I do quite a bit of this, and thought, can I flip the array, so around. Yeah baby you can! So here you go. This v2 with some bugs ironed out. Enjoy
function Flip-Array([Array]$Array, [String]$key){ $matrix =@() $KeyValue = @() $Array | ForEach{$KeyValue += $_.$key} $cols = @(); $cols += "Property" ; $cols += $keyValue $rows = @(); $array | Get-Member | Where {($_.MemberType -like "*Property") -AND ($_.Name -ne $key)} | ForEach{$Rows += $_.Name} $Rows = $Rows | sort unique $rows | ForEach{ $tmpMatrix = "" | Select $cols $tmpMatrix.Property = $_ $Matrix += $tmpMatrix } ForEach($item in $Array){ $ItemKey = $item.$key ForEach($Row in $Rows){ $itemvalue = $Item.$Row if($itemvalue.GetType.Name -like "MultiValued*"){$itemvalue = $Item.$Row -Join "!#!"} ($Matrix | Where {$_.Property -eq $row}).$ItemKey = $itemvalue } } $matrix = $matrix | sort property -Unique Return $Matrix } $e = get-exchangeserver $h = Flip-Array $e Name | ConvertTo-Html $h | out-file .\exchange.html