阻止$ ArrayList.Add输出新索引到主机?

Mac*_*inB 2 arrays indexing powershell arraylist output

在PowerShell中,如何防止[System.Collections.ArrayList]$ArrayList=@() ; $ArrayList.Add("New thing")将新索引的值发送到主机?

谢谢!

mjo*_*nor 5

您可以将结果转换为[void],或重定向到null

[void]$ArrayList.Add("New thing")
$ArrayList.Add("New thing") > $nul
$ArrayList.Add("New thing") | out-null
Run Code Online (Sandbox Code Playgroud)