Search notes:

PowerShell: Automatic variables

Automatic variables are created by PowerShell. They store the state of PowerShell.
$^ and $$ the first and last token that was received by a session. Apparently, the ^ and $ are modelled after their meaning in regular expressions (where they indicate the start or end of a line).
$? a boolean ($true or $false) that contains the status of the last operation. Compare with $lastExitCode which contains the exit code of the last native command or script that was run.
$_ for which $PsItem is an alias This automatic variable only makes sense inside a script block that is evaluated multiple times within a pipeline.
$args used for example for function parameters
$consoleFileName
$error
$event, $eventArgs and $eventSubscriber
$executionContext
$input set within the process and end block of functions within pipelines and refers to the objects as they're being processed from the function.
$isCoreCLR
$isLinux, $isMacOS and $isWindows
$lastExitCode
$true and $false constants for the two System.Boolean values.
$foreach
$home equivalent to $env:homeDrive$env:homePath and points to a user's home directory (for example C:\Users\username).
$host
$matches a collection that is populated when using regular expressions with the -match operator.
$myInvocation information about the current function, script or script block. This variable is especially useful to determine the name and location of a script within the script.
$nestedPromptLevel
$null
$PID The ID of the process hosting the current PowerShell session.
$psBoundParameters
$profile
$psCmdlet
$psCulture
$psDebugContext
$psStyle introduced in PowerShell 7.2 preview with the experimental feature PSAnsiRendering.
$psHome stores the path to the PowerShell installation directory (Usually C:\Windows\System32\WindowsPowerShell\v1.0 in non-Core PowerShell installations.). For example, predefined views are stored in this directory: ls $pshome -filter *.format.ps1xml
$psEdition indicates the used .NET runtime (PowerShell version 5.1 or higher).
$psVersionTable
$PSModuleAutoLoadingPreference controls the module autoloading behavior. Within a PowerShell script being executed, $psScriptRoot contains the absolute path of the directory where that script is located and $psCommandPath the absoulte path of the script itself. These variables evaluate to $null if they're not used within a script.
$PsUICulture
$pwd stores the current («present») working directory.
$sender corresponds to the object that generated an event.
$ShellID whose value might be Microsoft.PowerShell
$SourceArgs
$SourceEventArgs
$switch
$this

See also

Variables
System.Management.Automation.SpecialVariables
Some automatic variables are automatically placed into a scope when it is created

Index