现在的位置: 首页 > 综合 > 正文

PowerTip of the Day-Outputting Text Data to File

2012年11月10日 ⁄ 综合 ⁄ 共 941字 ⁄ 字号 评论关闭

原文地址:http://app.en25.com/e/es.aspx?s=1403&e=4695&elq=c3972de70bd84be5866111fbd6571d75

原文:

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.

 

翻译:

当要把一个输出结果输出到文本文件的 时候,你会发现相同宽度约束在输出到控制台的时候被应用了(此处没太看明白作者的意思,不过从后文看此处要说的应该是宽度太大导致某些列被省略而无法看到)。可以使用Format-TableOut-File-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仅用在确实有很多信息要被显示出来的情况,Out-FileWidth指定Format-Table可以使用的最大宽度。

 

笔记:

复习Format-Table

Width设置过小的话,超出部分的信息将会以省略。

抱歉!评论已关闭.