powershell 中的 System.Windows.Forms.ListView 隐藏输出

Min*_*bob 3 powershell listview winforms

用下面的代码

$listView = New-Object System.Windows.Forms.ListView
$listView.View = 'Details'
$listView.Width = 300
$listView.Height = 300
$listView.Columns.Add('User Name')
Run Code Online (Sandbox Code Playgroud)

DisplayIndex:0 索引:0 ImageIndex:-1 ImageList:ImageKey:ListView:System.Windows.Forms.ListView,Items.Count:0 名称:文本:用户名 TextAlign:左标签:宽度:60 站点:容器:

它在 powershell 控制台中输出以上内容。我怎样才能隐藏这个输出。

它干扰我在 -noconsole 模式下使用此脚本进行转换https://gallery.technet.microsoft.com/scriptcenter/PS2EXE-GUI-Convert-e7cb69d5

Rez*_*aei 5

要抑制输出,可以使用 out-null:

$listView.Columns.Add('User Name')|out-null
Run Code Online (Sandbox Code Playgroud)

此外,如果将其分配给变量,它会抑制输出:

$item = $listView.Columns.Add('User Name')
Run Code Online (Sandbox Code Playgroud)