How to Find and Reference Environment Variables in Windows PowerShell

Posted December 10, 2010 by Ben in Windows

In the classic Windows Command Processor, environment variables were referenced using “%” symbols surrounding the variable name. The environment variables were enumerated by simply typing “set” in the command prompt. This has changed considerably in PowerShell.

To find the currently set environment variables, open PowerShell and type the following:

Get-ChildItem Env:

Then to reference one of those items, simply append the “Name” value to $Env: in your command or script. E.g. type the following to change to the windows directory:

cd $env:windir

To elaborate on the options for the Get-ChildItem command, simply prepend it with “help”:

help Get-ChildItem

The Conversation

Follow the reactions below and share your own thoughts.