[英]What's the maximum number of columns for Format-Table cmdlet in PowerShell
[英]How to see all the columns in the Powershell in the Format-Table, regardless of the number of columns. (Missing columns)
无论列数如何,如何在 Format-Table 中查看 Powershell 中的所有列? 水平滚动会更可取以查看所有丢失的列。
这显示了所有列的名称:
$rows = Get-NetUDPEndpoint; $rows[0].psobject.Properties.Name;
但是,这里有许多缺失的列:
Get-NetUDPEndpoint| select * | ft -Autosize
Get-NetUDPEndpoint 默认有超过 15 列,但不是全部都显示在 format-Table 中
我们如何使用 Format-Table 显示所有列? 感谢所有可行的答案
注意:如果可以接受使用GUI 窗口显示表格,请考虑Santiago Squarzon建议使用Out-GridView
,它支持水平滚动:
# Shows table in a GUI window.
Get-NetUDPEndpoint| Select-Object * | Out-GridView
借助Out-String
及其-Width
参数,您可以使Format-Table
使用指定的行宽,而不是当前控制台窗口的(缓冲区)宽度:
# Choose a high enough number to pass to -Width.
# Note: Typically doesn't render meaningfully *on screen* - see below.
Get-NetUDPEndpoint | Format-Table * | Out-String -Width 1024
如果您将结果通过管道传输到文件并在文本编辑器中查看,您将获得所需的水平滚动。
但是,在控制台(终端)中,长于控制台窗口(缓冲区)宽度的行会换行,从而影响可读性。
只有 Windows 上的常规控制台窗口 ( conhost.exe
) 提供了解决方案:将窗口缓冲区宽度设置为相同:
# Note: Works in regular console windows on Windows only.
& {
param($width)
[Console]::BufferWidth = $with
Get-NetUDPEndpoint | Format-Table * | Out-String -Width $width
} 1024
不幸的是,上述方法不起作用:
在类 Unix 平台上的终端中,没有缓冲区宽度可以大于窗口宽度的概念,因此尝试设置缓冲区宽度会导致异常,超过窗口宽度的行会发生换行。
Windows 终端确实允许设置缓冲区宽度,这可以防止换行,但不支持水平滚动- 在GitHub 问题 #中讨论了缺少此功能。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.