Outputting Text Reports without Truncating

by Nov 21, 2011

If you want to capture PowerShell results in a text file, you can redirect the results or pipe them to Out-File. In any case, what you capture is the exact representation of what would have been displayed in your PowerShell console. So, depending on the amount of data, columns may be missing or truncated.

Here is a function called Out-Report. You can pipe any result to it to create a text file that does not truncate columns. In addition, with the –Open switch parameter, you can open the resulting text file, too:

function Out-Report {
 param(
  $Path = "$env:temp\report.txt",
  [switch]$Open
 )

 $Input | 
  Format-Table -AutoSize |
  Out-File $Path -Width 10000

  if($Open) { Invoke-Item $Path }
}

Try it:

Get-Process | Out-Report -Open

Twitter This Tip!
ReTweet this Tip!