Subscribe to Windows IT Pro
August 31, 2010 12:01 AM

Q. Why can't I pipe a formatted table to a CSV file?

Windows IT Pro
InstantDoc ID #125733
Rating: (1)

A. You can, but the CSV file will contain the output of the Format-Table cmdlet, which probably isn't what you want. Format cmdlets produce objects that tell the shell how to construct an on-screen display, which is why this produces such ugly output, as this example shows:

Get-Process | Format-Table | Export-CSV procs.csv

Generally, a Format cmdlet should be the LAST thing on your command line. The only exceptions are Out-File, Out-Host, and Out-Printer, which understand the output of a Format cmdlet. These cmdlets work fine, as this code shows:

Get-Process | Format-Table | Out-File procs.txt

If you want processes in a CSV file, just skip the table:

Get-Process | Export-CSV procs.csv

 

Do you have a Windows PowerShell question? Why not submit it to Don? Post your question at www.windowsitpro.com/FAQs/FAQSubmittalForm.aspx and you might see your answer online! Find more PowerShell FAQs, articles, and other resources at windowsitpro.com/go/DonJonesPowerShell.

 

Related Content:

ARTICLE TOOLS

Comments
    There are no comments to display. Be the first one!
You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.