PowerTip of the Day, from PowerShell.com:
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:
1: function Out-Report {
2:
3: param(
4:
5: $Path = "$env:temp\report.txt",
6:
7: [switch]$Open
8:
9: )
10:
11:
12:
13: $Input |
14:
15: Format-Table -AutoSize |
16:
17: Out-File $Path -Width 10000
18:
19:
20:
21: if($Open) { Invoke-Item $Path }
22:
23: }
Try it:
Get-Process | Out-Report -Open
Thanks
Aman
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.