Common reserved variables

Refer to the following table:

Errors

$Error
$Error[0]    # The last error

Formats the enumeration limit. Dictates the number of elements displayed for objects with properties based on arrays.

The default is 4.

$FormatEnumerationLimit
$object = [PSCustomObject]@{
Array = @(1, 2, 3, 4, 5)
}
$object # Shows 1, 2, 3, and 4
$formatenumerationlimit = 1
$object # Shows 1

Holds data of the current PowerShell host.

$Host
$host
$host.UI.RawUI.WindowTitle
The matches found when using the -match operator. $Matches
‘text’ –match ‘.*’
$matches

The output field separator.

The default is a single space.

Dictates how arrays are joined when included in an expandable string.
$OFS
$arr = 1, 2, 3, 4
“Joined based on OFS: $arr”
$ofs = ‘, ‘
“Joined based on OFS: $arr”

Current PowerShell process ID.

$PID
Get-Process –Id $PID

Holds the path to each of the profile files.

$PROFILE
$profile.AllUsersAllHosts
$profile.AllUsersCurrentHost
$profile.CurrentUserAllHosts
$profile.CurrentUserCurrentHost

PowerShell version information.

$PSVersionTable

$PSVersionTable.PSVersion

Present working directory.

$PWD
$PWD.Path
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.205.235