# Swaptable # # reads objects with properties from the pipeline and sends a object per Property to the pipeline # if viewed as a table is will swap Rows and colums. # useful if oyu have a few objects (like ReceiveConnectors) and want to compare them or view them als table. # A table with two rows and many columns is not very useful. # # Version 1.0 20130507 Initial Version to compare Lync Conference Policies. write-verbose "Swaptable: ============== started ============== " $pipelinearray = @($input) if (($pipelinearray.count -eq 0) -or ($pipelinearray -eq $null)) { write-error "Swaptable: Pipeline is empty" } if ($pipelinearray.count -eq 1) { write-warning "Swaptable: Pipeline has only one element" } else { write-verbose "Loading Properties from first element" #$pipelinearray $properties = ($pipelinearray[0] | gm -MemberType Property,NoteProperty) write-verbose "Creating Output Objekt template" $templatepso =new-object psObject Add-Member -inputobject $templatepso -MemberType noteproperty -Name "0" -Value "" [int]$count=1 foreach ($colname in ($pipelinearray)) { write-verbose ("Adding Col " + $colname.$col) Add-Member -inputobject $templatepso -MemberType noteproperty -Name $count.tostring() -Value "" $count+=1 } write-verbose "TemplatePSO" $templatepso write-verbose "Parsing Output" foreach ($rowname in ($properties)) { write-verbose ("Collecting data für Row:" + $rowname.name) $outpso = ($templatepso | select *) # create a copy of the object $outpso."0" = $rowname.name [int]$count=1 foreach ($obj in $pipelinearray){ write-verbose (" Processing Object:" + ($count.tostring()) + "=" + $obj.($rowname.name)) $outpso.$count = ($obj.($rowname.name)) $count+=1 } $outpso } } write-verbose "Swaptable: ============== ended ============== "