Skip to content

Latest commit

 

History

History

Unexpected-output

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

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