Windows: List all environment variables (CMD, PowerShell)
Introduction
To list all environment variables in Windows, run set in the Command Prompt (cmd) or Get-ChildItem Env: in PowerShell.
To print or check a single variable, run echo %NAME% in the Command Prompt or $env:NAME in PowerShell.
To see the user and system variables Windows stores for new processes, open the Environment Variables dialog from System Properties (sysdm.cpl).
set, Get-ChildItem Env: and the Environment Variables dialog have worked the same way since Windows XP, and they still do in Windows 11.
In this post, I'll show you how to list all environment variables in Windows, print a single one, tell user variables from system variables, and read the PATH, both from the command line and from the Windows GUI.
I checked every command against Microsoft's documentation in October 2026, for Windows PowerShell 5.1 and PowerShell 7.6.7.
- Quick reference
- From cmd
- From PowerShell
- User and system variables
- From the Windows Graphical User Interface (GUI)
- The PATH variable
- Why a new variable doesn't show up
Quick reference: Command Prompt and PowerShell
| Task | Command Prompt (cmd) | PowerShell |
|---|---|---|
| List all | set | Get-ChildItem Env: |
| Names starting with JAVA | set JAVA | Get-ChildItem Env:JAVA* |
| Print one variable | echo %JAVA_HOME% | $env:JAVA_HOME |
| Print the PATH | path | $env:Path -split ';' |
| Stored user variables | reg query HKCU\Environment | [Environment]::GetEnvironmentVariables('User') |
| Stored system variables | reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" | [Environment]::GetEnvironmentVariables('Machine') |
Each process gets its own copy of the environment when it starts: the system variables (shared by every user), your user variables, and anything its parent process added.
That's why set and Get-ChildItem Env: show what the current window sees, which can differ from what Windows has stored.
On Windows, variable names are not case-sensitive: %PATH%, %Path% and $env:path all refer to the same variable.
How to list all environment variables from cmd
Open a new command prompt (Win+R, then type cmd and hit enter) and type:
setThe command outputs a list of all the environment variable names and values separated by an equal sign (=).

Since Windows 11 version 22H2, Windows Terminal is the default console, so cmd opens in a Windows Terminal tab.
The commands are the same: they depend on the shell (Command Prompt or PowerShell), not on the window that hosts it.
How to filter the output of set
If you pass set a name, it lists only the variables whose name starts with it:
set JAVATo search for a word anywhere in the names and values, pipe the output to findstr:
set | findstr /i "path"The command now outputs only the lines that contain the word path, such as Path and PATHEXT.
Add the /i flag: findstr is case-sensitive by default, and in a default Windows installation the variable is called Path, so findstr "PATH" would skip it.

How to print (echo) or check a single environment variable in cmd
To print the value of a single variable, wrap its name in percent signs:
echo %JAVA_HOME%The Command Prompt replaces %JAVA_HOME% with the value of the variable before it runs echo.
If the variable isn't defined, the Command Prompt leaves the text as it is and prints %JAVA_HOME%.
To check whether a variable is defined, for example in a batch file, use if defined:
if defined JAVA_HOME (echo JAVA_HOME is set) else (echo JAVA_HOME is not set)How to list all environment variables from PowerShell
PowerShell is the newer command-line shell and scripting language for Windows, and it exposes the environment variables as a drive called Env:.
PowerShell 1.0 came out in November 2006 as an optional download for Windows XP, and Windows 7 was the first Windows client to include it.
As of October 2026, Windows 10 and Windows 11 ship Windows PowerShell 5.1, which opens with powershell, and the cross-platform PowerShell 7 installs alongside it, with the command pwsh.
Every command in this section works in both.
PowerShell offers multiple ways to list all environment variables.
The easiest one is to use the Get-ChildItem cmdlet.
Using Get-ChildItem
Open a new PowerShell prompt (Win+R, then type powershell and hit enter) and type:
Get-ChildItem Env:The command outputs a list of all the environment variable names and values in a table format.

The table cuts long values short, like the Path in the screenshot.
To see them whole, sort the list by name and format it as a list:
Get-ChildItem Env: | Sort-Object Name | Format-ListYou can also filter by name with a wildcard, or by value with Where-Object:
Get-ChildItem Env:*JAVA*
Get-ChildItem Env: | Where-Object Value -like '*Java*'Using one of the Get-ChildItem aliases
Typing Get-ChildItem is a bit long, so PowerShell offers some aliases to make it easier to use.
You can use any of the following commands to get the same result:
gci Env:dir Env:ls Env:(thelsalias exists on Windows only; PowerShell on Linux and macOS leaveslsto the system command)
ls Env:The command outputs the same as the Get-ChildItem Env: command.

The main advantage of the PowerShell approach is that you can provide many options to the cmdlet to customize its output for your needs.
How to get a single environment variable in PowerShell
To print the value of a single variable, prefix its name with $env::
$env:JAVA_HOMEThe Command Prompt syntax doesn't work here: in PowerShell, echo %JAVA_HOME% prints the text %JAVA_HOME% as it is.
If the variable doesn't exist, $env:JAVA_HOME prints nothing; to check whether it's defined, use Test-Path, which returns True or False:
Test-Path Env:JAVA_HOMEYou can also read a variable through .NET, which is handy in scripts:
[Environment]::GetEnvironmentVariable('JAVA_HOME')How to list user and system environment variables separately
Windows stores the variables you define in two places, and builds your sign-in environment from both:
- System variables apply to every user, and only administrators can change them.
Windows stores them in the
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environmentregistry key. - User variables apply to your account only.
Windows stores them in the
HKEY_CURRENT_USER\Environmentregistry key.
set and Get-ChildItem Env: show the merged result, plus variables Windows sets for each session, such as USERNAME and USERPROFILE, and anything set in the current window.
To list each group on its own, pass a target to GetEnvironmentVariables in PowerShell:
[Environment]::GetEnvironmentVariables('User')
[Environment]::GetEnvironmentVariables('Machine')The target can be Process (the current session, the default), User or Machine.
The output isn't sorted; to sort it by name, enumerate it first:
[Environment]::GetEnvironmentVariables('User').GetEnumerator() | Sort-Object NameFrom the Command Prompt, you can read the same registry keys with reg query:
reg query HKCU\Environment
reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment"reg query prints the values as stored, so the system Path shows entries such as %SystemRoot%\system32 unexpanded.
How to check environment variables from the Windows Graphical User Interface (GUI)
If you don't need to use this output in a script, or you just prefer the Windows GUI, you can check the environment variables from the System Properties window.
In Windows 11 and Windows 10, the quickest way is to type environment in the Start menu search and open Edit the system environment variables.
The same search also shows Edit environment variables for your account, which opens the Environment Variables dialog directly, without asking for administrator rights, to edit your user variables.
You can also reach it from Settings > System > About > Advanced system settings.
The Run dialog works in every version since Windows XP: press the Win+R keys, type sysdm.cpl and hit enter.

Next, click on the Advanced tab and then on the Environment Variables button.

The Environment Variables dialog will open. The upper list shows the user variables for your account, and the lower list shows the system variables. You need administrator rights to change the system variables.

The dialog shows what Windows stores, not what an open Command Prompt or PowerShell window sees: a value you change here only reaches the programs you start afterwards.
If you edit environment variables often, Microsoft's free PowerToys includes an Environment Variables utility that lists the user and system variables, lets you edit them, and shows the values that apply, Path included.
How to view the PATH environment variable
The PATH variable holds the list of directories where Windows looks for executables, separated by semicolons (;).
In the Command Prompt, the path command with no arguments prints it, prefixed with PATH=:
pathThe value is a single long line, which is hard to read. In PowerShell, split it to print one directory per line:
$env:Path -split ';'The Path of a session combines the system Path and your user Path.
To see each of them on its own, read them with their target:
[Environment]::GetEnvironmentVariable('Path', 'Machine') -split ';'
[Environment]::GetEnvironmentVariable('Path', 'User') -split ';'Why doesn't a new environment variable show up?
A process gets its environment when it starts, so a window that was already open doesn't see later changes.
set NAME=valuein the Command Prompt and$env:NAME = 'value'in PowerShell change the current session only, and the change is gone when you close the window.- The Environment Variables dialog and the
setxcommand store the variable in the registry, so it persists, but only programs you start afterwards see it. Open a new Command Prompt or PowerShell window; if the variable is still missing, close and reopen the terminal app or the editor you started it from.
Be careful with setx PATH "%PATH%;C:\Tools", a command you'll find in many guides: %PATH% expands to the system and user Path combined, setx writes all of it into your user Path, and it truncates any value longer than 1,024 characters.
To add a directory to the PATH for good, edit the user or the system Path in the Environment Variables dialog instead.
That's how I added Maven to the PATH in my guide to installing Apache Maven on Windows.
Conclusion
In this post, I have shown you the possible ways to list all environment variables in Windows, something you'll need sooner or later when developing or administrating a system.
From the command line, set in the Command Prompt and Get-ChildItem Env: in PowerShell list every variable of the current session, and echo %NAME% or $env:NAME print a single one.
[Environment]::GetEnvironmentVariables and reg query show the user and system variables Windows stores, and the plain old Environment Variables dialog shows both in the GUI.
The core commands, set and Get-ChildItem Env:, have worked the same way since Windows XP, so they should work on whichever version you're on.
I hope you find it useful.
