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

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? Find more PowerShell FAQs, articles, and other resources at windowsitpro.com/go/DonJonesPowerShell.