Commonly-used shell variables

PowerShell and the Exchange Management Shell provide several automatic variables. The following table provides a list of commonly-used automatic variables with a description for each one:

Variable Name

Description

$$

This contains the last token in the last command received.

$?

This contains the execution status of the last command.

$^

This contains the first token in the last command received.

$_

This contains the current object being processed within a pipeline.

$Args

This contains an array of undeclared arguments received by a function, script, or script block.

$Error

This contains an array of error objects recorded in the current shell session. The latest error ...

Get Microsoft Exchange Server 2016 PowerShell Cookbook - Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.