I would prefer this method to redirect standard output (native PowerShell) ...
($foo = someFunction) | out-null
But this also works:
($foo = someFunction) > $null
To redirect only the standard error after defining $ foo with the result "someFunction", do
($foo = someFunction) 2> $null
This is actually the same as above.
Or redirect any standard error messages from "someFunction", and then define $ foo with the result:
$foo = (someFunction 2> $null)
To redirect both options, you have several options:
2>&1>$null 2>&1 | out-null
J Bills Jun 23 2018-11-11T00: 00Z
source share