$_
is an alias for $psItem
. 'foo', 'bar', 'baz' | forEach-object { write-host $_ } 'foo', 'bar', 'baz' | forEach-object { write-host $psItem }
$_
refers to the object that is received from the last step in the pipeline. catch
block, $_
refers to the exception object (whose type is System.Management.Automation.ErrorRecord
) that caused the catch
block to be invoked.