views:

41

answers:

2

In a PowerShell script, I have some objects that I pass to the Format-Table CmdLet.
The output of my script looks like this:

Something...

Operation AttributeName  AttributeValue
--------- -------------  --------------
Delete    Member         John Doe

Something else...

Since the meaning of the fields is pretty self-explanatory, I would like to remove the headers, the '---' separators and the blank lines at the beginning and at the end from the output of Format-Table.
I don't think that the CmdLet supports this (or at least if there's a parameter to do this I couldn't find it).

What would the best way to leave only the lines with the actual values from the output of Format-Table?

+3  A: 

Try the -HideTableHeaders parameter to Format-Table:

gci | ft -HideTableHeaders

(I'm using PowerShell v2. I don't know if this was in v1.)

Jay Bazuzi
Completely missed the parameter :(Thanks!
Paolo Tedesco
New-Alias rtfm Get-Help # :)
JasonMArcher
A: 

The -HideTableHeaders parameter unfortunately still causes the empty lines to be printed (and table headers appearently are still considered for column width). The only way I know that could reliably work here would be to format the output yourself:

| % { '{0,10} {1,20} {2,20}' -f $_.Operation,$_.AttributeName,$_.AttributeValue }
Joey