powershell - 从表输出中删除椭圆

标签 powershell

我正在尝试将 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

enter image description here

我还尝试从管道中删除 Out-String 没有什么区别。

这里出了什么问题?

谢谢

最佳答案

Compare-Object $Hive1FileArray $Hive2FileArray -IncludeEqual |`
     Format-Table $tableFormat -AutoSize |`
        Out-String -Width 1000 |`
            Out-File $outputFilename

阅读

-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.

-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/

相关文章:

powershell - 通过GPO设置事件日志设置

powershell - 使用 csv 的 ForEach 中的 If 语句

powershell - PowerShell 中的停止器(程序执行期间耗时)

c - 从 C 调用的 Powershell 脚本不会打开 OleDb 连接

powershell - Powershell get-eventlog消息列太短

powershell - 使用 powershell(或其他非外部软件)进行鼠标单击自动化

powershell - Update-Module 复制模块而不是更新

powershell - 试图理解这段代码(创建一个 [char] 范围)

.net - 如何在 Windows 2012 R2 Core 上的代理后面安装 Chocolatey 软件包?

c# - 在自定义 C# PowerShell Cmdlet 中确定是否指定了 -Verbose