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 |
---|---|
Contains the last token in the last command received. | |
Contains the execution status of the last command. | |
Contains the first token in the last command received. | |
Contains the current object being processed within a pipeline. | |
Contains an array of undeclared arguments received by function, script, or script block. | |
Contains an array of error objects recorded in the current shell session. The latest error can be accessed using the zero index of the array, that is, | |
References the full path to the Exchange Server\Bin directory. This variable is only present when starting the shell using the Exchange Management Shell shortcut on a machine with the Exchange tools installed. | |
References the full path to the Exchange scripts directory. This variable is only present when starting the shell using the Exchange Management Shell shortcut on a machine with the Exchange tools installed. | |
Provides a Boolean false value when used in commands and scripts. | |
Contains the enumerator inside a ForEach-Object loop. | |
Contains the full path to the user's home directory. | |
Contains an object that represents the current PowerShell host application. | |
Contains the enumerator for items passed to a function. The | |
Specifies the maximum number of entries that can be saved in the command history in the current shell session. | |
Provides a NULL or empty value when used in commands and scripts. | |
Contains the full path to the PowerShell profile for the current user and current host application. | |
Contains the full path to the installation directory of Windows PowerShell. | |
Contains the path to the current location. | |
Provides a Boolean true value. |
To view the variables currently defined in your shell session, run Get-Variable
. You can also read more about PowerShell variables by running the Get-Help <TopicName>
cmdlet on the following About topics:
about_Automatic_Variables
about_Environment_Variables
about_Preference_Variables