How can I supress the detailed information from Test-NetConnection -ComputerName localhost
for a PowerShell session?
Test-NetConnection
writes quite a bit of information to the console which is displayed in the top of the console, overwriting the progress bar.
The output can be suppressed by setting the -InformationLevel
to Quiet
like so
It looked like the output could be supressed like with the -InformationLevel
parameter, however it turns out that even with -InformationLevel
to Quiet
the information in the top of the console is shown.
Test-NetConnection -ComputerName localhost -InformationLevel Quiet
I would like to set the InformationLevel
just once for the whole script, like you would suppress the progress bar when using Invoke-WebRequest
.
$progressPreference = 'silentlyContinue' # Subsequent calls do not display UI.
Invoke-WebRequest ...
$progressPreference = 'Continue' # Subsequent calls do display UI.
To my knowledge there is no similar $InformationLevelPreference
Test-NetConnection will listen to.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…