Outputting Text Data to File

by May 21, 2010

When you output results to text files, you will find that the same width restrictions apply that are active when you output into the console. You should use a combination of Format-Table and Out-File with -Width to allow more width.

Get-Process |
Format-Table Name, Description, Company, StartTime -AutoSize |
Out-File $home\result.txt -Width 1000
Invoke-Item "$home\result.txt"

Format-Table -AutoSize uses only as much width as is needed to display all information, and Out-File -Width specifies the maximum width that Format-Table can use.

Twitter This Tip! ReTweet this Tip!