PowerShell One-Liner: Getting Local Environment Variables

In some upcoming articles, I'll show how to add, modify, and delete environment variables, and then give some examples of how to utilize them. But, let's start by finding out what's available for use.

Rod Trent

July 11, 2013

1 Min Read
PowerShell One-Liner: Getting Local Environment Variables

Before you can start working with the computer's environment variables, it helps to be able to retrieve the current list to show what's available to work with. In some upcoming articles, I'll show how to add, modify, and delete environment variables, and then give some examples of how to utilize them. But, let's start by finding out what's available for use.

Retrieving the list of current environment variables is as simple as running this in Windows PowerShell:

Get-ChildItem Env:

Once you kick off that quick command, something similar to the following will display for you:

After you have the names and values, you can even pare down your results to specific environment variables. Using the PATHEXT from the Namecolumn, run the same command as before except insert PATHEXT at the end like this:

Get-ChildItem Env:PATHEXT

Quick and simple, that single modification retrieves just the Value for the PATHEXT as shown in the following image:

 

 

Part 2: PowerShell One-Liner: Creating and Modifying an Environment Variable

Part 3: PowerShell One-Liner: Deleting Environment Variables

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like