我正在尝试将 powershell cmdlet Compare-Object
的结果输出到文本文件,问题是我无法消除椭圆截断。
下面的代码提供了一个表格式定义变量,该变量指定“路径”列的宽度为 1000。然而输出文件总是将 Path 列截断为 122 个字符。
Compare-Object
cmdlet 正在比较两个 ArrayList,这两个 ArrayList 只是两个服务器之间的公共(public)文件夹路径中的文件路径字符串列表。
我试图做的是将 SideIndicator 作为第一列,将完整路径放在第二列中。我不想截断文件路径。
$tableFormat = @{Expression={$_.SideIndicator};Label="Side Indicator";width=15}, @{Expression={$_.InputObject};Label="Path";width=1000}
$outputFilename = ($server1 + "_" + $server2 + "_FileCompare" + ".txt");
Compare-Object $Hive1FileArray $Hive2FileArray -IncludeEqual | Format-Table $tableFormat | Out-String | Out-File $outputFilename
我还尝试从管道中删除 Out-String
没有什么区别。
这里出了什么问题?
谢谢
最佳答案
Compare-Object $Hive1FileArray $Hive2FileArray -IncludeEqual |`
Format-Table $tableFormat -AutoSize |`
Out-String -Width 1000 |`
Out-File $outputFilename
阅读
Get-Help 'Format-Table' -ShowWindow
或其 Online Version :
-AutoSize
Adjusts the column size and number of columns based on the width of the data. By default, the column size and number are determined by the view.
Get-Help 'Out-String' -ShowWindow
或其 Online Version :
-Width <Int32>
Specifies the number of characters in each line of output. Any additional characters are truncated, not wrapped. If you omit this parameter, the width is determined by the characteristics of the host program. The default value for the Windows PowerShell console is 80 (characters).
不多说了,不知道 Compare-Object
cmdlet 输入对象...
关于powershell - 从表输出中删除椭圆,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36505570/