PowerTip of the Day-Outputting Text Data to File

本文介绍如何使用Format-Table和Out-File命令解决输出结果到文本文件时遇到的宽度限制问题,确保所有信息完整显示。

原文地址: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设置过小的话,超出部分的信息将会以省略。

转载于:https://www.cnblogs.com/aspnetx/archive/2010/06/22/1762406.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值