Skip navigation
PowerShell One-Liner: Getting Local Environment Variables

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. 

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

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish