Skip to content

Files

Latest commit

ff719dc · Jun 17, 2022

History

History

Unexpected-output

Unexpected output

PowerShell outputs everything which is evaluated to something, even without Write-Output, return, and etc. This may result in unexpected output.

For example, for ArrayList.Add or StringBuilder.Append it is easy to forget that these methods return values and they become part of the output unless they are somehow used, e.g. assigned to a variable, or explicitly discarded.

Unused output of some statements should be discarded, for example

    $null = ...
    [void](...)
    ... > $null
    ... | Out-Null

Scripts