Outputting Text Data to File

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!


Posted May 21 2010, 08:00 AM by ps1
Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.