PowerShell: Format-Table without headers

Viewed 122680

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?

6 Answers

Here is how I solve this. I just pipe the output to Out-String and then pass that output to the .NET Trim function:

(gci | ft -HideTableHeaders | Out-String).Trim()

This will strip out the line breaks before and after the table.

You can also use TrimStart to just take care of the header's line break if you still want the trailing line breaks.

(gci | ft -HideTableHeaders | Out-String).TrimStart()
Related