O'Reilly logo

Windows PowerShell Quick Reference by Lee Holmes

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

PowerShell Automatic Variables

Windows PowerShell Automatic Variables

Variables automatically used and set by Windows PowerShell

Variable

Meaning

$$

Last token of the last line received by the shell.

$?

Success/fail status of the last operation.

$^

First token of the last line received by the shell.

$_

Current pipeline object in a pipelined script block.

$args

Array of parameters passed to the script, function, or scriptblock.

$confirmPreference

Preference that controls the level of impact that operations may have before requesting confirmation. Supports the values low, medium, high. A value of none disables confirmation messages.

$consoleFilename

Filename of the PowerShell console file that configured this session.

$currentlyExecutingCommand

Currently executing command, when in a suspended prompt.

$debugPreference

Preference that controls how PowerShell should handle debug output written by a script or cmdlet. Supports the values SilentlyContinue, Continue, Inquire, and Stop.

$error

Array that holds the (terminating and non-terminating) errors generated in the shell.

$errorActionPreference

Preference that controls how PowerShell should handle error output written by a script or cmdlet.

 

Supports the values SilentlyContinue, Continue, Inquire, and Stop.

$errorView

Preference that controls how PowerShell should output errors in the shell. Supports the values of Normal, and CategoryView (a more succinct and categorical view of the error.)

$executionContext

Means by which scripts can access the APIs typically used ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required