PowerShell Common – Automatic Variables

Today we are going to talk about the Automatic Variables that PowerShell provides for us. Automatic variables are provided by the PowerShell Team to allow us to grab key scripting functions. I commonly use $False, $True, and $Pwd in my scripts. To get a list of all the Automatic Variables we need to run get-help about_automatic_variables. You might have to run Update-Help before running the Get-Help.

The following variables are just some of the most used:

$Event - "Contains a PSEventArgs object that represents the event that is being processed."
$False - "Contains FALSE."
$Home - "Contains the full path of the users home directory."
$NULL - "Contains a NULL or empty value."
$PID - "Contains the process identifier (PID) of the process that is hosting the current Windows PowerShell session."
$PsCmdlet - "Contains an object that represents the cmdlet or advanced function that is being run."
$PSScriptRoot - "Contains the directory from which the script module is being executed."
$PsHome - "Contains the full path of the installation directory for Windows PowerShell."
$PSVersionTable - "Contains a read-only hash table that displays details about the version of PowerShell that is running in the current session."
$Pwd - "Contains a path object that represents the full path of the current directory."
$True - "Contains TRUE."
Advertisements

2 thoughts on “PowerShell Common – Automatic Variables

  1. Pingback: Building a Powershell Toolkit – DESKTOP 3nG1n33R1ng

  2. Pingback: Determine Installed PowerShell Version | ZOTech Consulting

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s