The shell defines a number of automatic variables that have special meaning depending on their context within the shell (see Table A-9). See the help about_automatic_variables page for an exhaustive list.
Table A-9. Automatic variables
Variable | Value |
|---|
$? | Success/fail status of the previous operation |
$_ | Contains the current pipeline object |
$^ | Contains the first token of the last line received by the shell |
$$ | Contains the last token of the last line received by the shell |
$args | Contains the set of command-line options passed to a function, filter, or script after any named parameters are consumed |
$input | Contains an enumerator of objects entering a function from the pipeline |
$lastexitcode | The error level return from the last external command |
$error | Array of errors (first element is the most recent) |
$null | Null |
$true | Boolean true value |
$false | Boolean false value |