You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
www.explainpowershell.com considers the automatic variables '$_' and '$PsItem' as linked to a pipeline.
For the following examples this is not the case, at least not in the submitted code because the pipe character '|' does not exist.
A beginner may therefore be disappointed by the explanation given so far.
With :
From the PS v3 specification document (8.6 The switch statement): Switch :
on entry to each statement-block, $_ is automatically assigned the value of the switch-condition that caused control to go to that statement-block.
$_ is also available in that statement-block's switch-clause-condition.
For throw :
Within a matching catch clause, the variable $_ contains a description of the current exception.
For trap {"Error found: $psitem"}
Within a trap statement the variable $_ contains a description of the current error.
There are also Winform and WPF eventhandlers, but that's off topic here :
Note :
The constructions submitted here are suitable because only one line can be entered.
The text was updated successfully, but these errors were encountered:
Jawz84
changed the title
One remark about automatic variable pipeline
Explanation should be refined for '$_' in scriptblocks without pipeline.
Jul 1, 2022
www.explainpowershell.com considers the automatic variables '$_' and '$PsItem' as linked to a pipeline.
For the following examples this is not the case, at least not in the submitted code because the pipe character '|' does not exist.
A beginner may therefore be disappointed by the explanation given so far.
With :
From the PS v3 specification document (8.6 The switch statement):
Switch :
For throw :
For trap {"Error found: $psitem"}
There are also Winform and WPF eventhandlers, but that's off topic here :
Note :
The constructions submitted here are suitable because only one line can be entered.
The text was updated successfully, but these errors were encountered: