![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Formating objects I want to collect info from various servers and output to the console via format-table. Say the info I'm collecting is : Property1,Property2,Property3,Property4 I want the output to look like (when formatted with format-table): Property1 Property2 Property3 Property4 --------- --------- --------- --------- Value1 Value2 Value3 Value4 Value1 Value2 Value3 Value4 Value1 Value2 Value3 Value4 Value1 Value2 Value3 Value4 (...) I used System.Management.Automation.PSObject and added new NoteProperty with Add-Member but the final output repeats itself for each server: Property1 Property2 Property3 Property4 --------- --------- --------- --------- Value1 Value2 Value3 Value4 Value1 Value2 Value3 Value4 (...) Property1 Property2 Property3 Property4 --------- --------- --------- --------- Value1 Value2 Value3 Value4 Value1 Value2 Value3 Value4 (...) I can emit the property names once (header row), and then use [string]::format("{0} {1}", $_.prop1 ,$_.prop2) to emit each table row, but I prefer format-table as it supports the -autosize parameter. Shay http://scriptolog.blogspot.com |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Formating objects "Shay Levi" <no@xxxxxx> wrote in message news:8766a9446bc58c9c106e790b3d0@xxxxxx Quote: >I want to collect info from various servers and output to the console via > format-table. > Say the info I'm collecting is : Property1,Property2,Property3,Property4 > > I want the output to look like (when formatted with format-table): > > Property1 Property2 Property3 Property4 > --------- --------- --------- --------- > Value1 Value2 Value3 Value4 > Value1 Value2 Value3 Value4 > Value1 Value2 Value3 Value4 > Value1 Value2 Value3 Value4 > (...) > > > I used System.Management.Automation.PSObject and added new NoteProperty with > Add-Member > but the final output repeats itself for each server: > > > Property1 Property2 Property3 Property4 > --------- --------- --------- --------- > Value1 Value2 Value3 Value4 > Value1 Value2 Value3 Value4 > (...) > > Property1 Property2 Property3 Property4 > --------- --------- --------- --------- > Value1 Value2 Value3 Value4 > Value1 Value2 Value3 Value4 > (...) > > > I can emit the property names once (header row), and then use [string]::format("{0} > {1}", $_.prop1 ,$_.prop2) to emit each > table row, but I prefer format-table as it supports the -autosize parameter. PS C:\> gps w* | %{$obj = new-object psobject;add-member -inp $obj NoteProperty Prop1 $_.Name;add-member -inp $obj NoteProperty Prop2 $_.Id; $obj} | ft -auto Prop1 Prop2 ----- ----- WindowClippings_x86 3248 wininit 612 winlogon 768 I think we need to see how you are collecting and adding the server info into the psobject. -- Keith |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Formating objects Oh.. man 10Q Shay http://scriptolog.blogspot.com Quote: > "Shay Levi" <no@xxxxxx> wrote in message > news:8766a9446bc58c9c106e790b3d0@xxxxxx > Quote: >> I want to collect info from various servers and output to the console >> via >> format-table. >> Say the info I'm collecting is : >> Property1,Property2,Property3,Property4 >> I want the output to look like (when formatted with format-table): >> >> Property1 Property2 Property3 Property4 >> --------- --------- --------- --------- >> Value1 Value2 Value3 Value4 >> Value1 Value2 Value3 Value4 >> Value1 Value2 Value3 Value4 >> Value1 Value2 Value3 Value4 >> (...) >> I used System.Management.Automation.PSObject and added new >> NoteProperty with Add-Member but the final output repeats itself for >> each server: >> >> Property1 Property2 Property3 Property4 >> --------- --------- --------- --------- >> Value1 Value2 Value3 Value4 >> Value1 Value2 Value3 Value4 >> (...) >> Property1 Property2 Property3 Property4 >> --------- --------- --------- --------- >> Value1 Value2 Value3 Value4 >> Value1 Value2 Value3 Value4 >> (...) >> I can emit the property names once (header row), and then use >> [string]::format("{0} >> {1}", $_.prop1 ,$_.prop2) to emit each >> table row, but I prefer format-table as it supports the -autosize >> parameter. > > PS C:\> gps w* | %{$obj = new-object psobject;add-member -inp $obj > NoteProperty Prop1 $_.Name;add-member -inp $obj NoteProperty Prop2 > $_.Id; $obj} | ft -auto > > Prop1 Prop2 > > ----- ----- Quote: >> WindowClippings_x86 3248 >> wininit 612 >> winlogon 768 >> I think we need to see how you are collecting and adding the server >> info into the psobject. >> >> -- >> Keith |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Why was formating unsuccessful? | Vista General | |||
| Formating HD | Vista installation & setup | |||
| Formating Help | General Discussion | |||
| HDD Formating | Vista hardware & devices | |||
| Formating my PC | Vista hardware & devices | |||