Shorter version:

gci env:* | sort-object name

This will display both the name and value.

Answer from jaymjarri on Stack Overflow
Discussions

How to print all environment variables by scope? e.g. Process, Machine and User
You can get them the same way you set them [System.Environment]::GetEnvironmentVariables([System.EnvironmentVariableTarget]::Machine) [System.Environment]::GetEnvironmentVariables([System.EnvironmentVariableTarget]::User) [System.Environment]::GetEnvironmentVariables([System.EnvironmentVariableTarget]::Process) More on reddit.com
🌐 r/PowerShell
16
4
March 28, 2019
Please help me understand the purpose of environments in PowerShell
Powershell has no "Environments". If they " look similar to variables", you're most likely talking about environment variables. They are not related to Powershell, they are part of the environment the OS provides to process. They provide information to the processes. Partly they are maintained by the OS itself, partly they are user maintained to configure and control processes. More on reddit.com
🌐 r/PowerShell
42
11
December 25, 2023
env and environment variables in Powershell
$env is a powershell object just like $true. If you want to set an environment variable there's 2 normal ways to do it, one using $env, the second using [Environment]::SetEnvironmentVariable Using $env will only set the variable for the current powershell process, whereas using [Environment]::SetEnvironmentVariable you can set it for different areas (process, user, or machine). When you do $INCLUDE you're not setting an environment variable, you're just creating a variable called $INCLUDE. see http://technet.microsoft.com/en-us/library/ff730964.aspx More on reddit.com
🌐 r/PowerShell
5
8
December 7, 2014
Environment Variable inside a single '
There are a lot of different ways to do this, I like PowerShell's flexibility when dealing with strings. Single quotes do indeed turn everything literal. however, single quotes are literal inside of double quotes msiexec wont care if the path is encased in single or double quotes so you could use single quotes in your string -ArgumentList "/I '$env:temp\My MSI File.msi' /qn" You could also escape the double quote with a back tick -ArgumentList "/I `"$env:temp\My MSI File.msi`" /qn" Unrelated to your post but helpful when dealing with strings. If you are trying to access a property in an object that is a string it can be formatted like this "This is the users first name $($user.firstname)" More on reddit.com
🌐 r/PowerShell
6
14
November 10, 2021
People also ask

How do I list all variables in PowerShell?

To list all variables in your PowerShell session, you can use:

Get-ChildItem Env:

This command will show all currently defined variables in the session, including environment variables.

🌐
netwrix.com
netwrix.com › home › resources › blog › powershell environment variables
PowerShell Environment Variables
How to set an environment variable using PowerShell?

To set an environment variable, you can use the following syntax.

$Env:VariableName = “Value”

Replace VariableName with the desired name of your variable and Value with the value you want to assign to it, as example below.

$Env:MY_VAR = “MyValue”

🌐
netwrix.com
netwrix.com › home › resources › blog › powershell environment variables
PowerShell Environment Variables
How to check if an environment variable exists in PowerShell?

To check if a specific environment variable exists, you can use the following command.

Test-Path Env:MY_VAR Replace MY_VAR with the name of the environment variable you want to check. If the variable exists, it will return True; if not, it will return False.

🌐
netwrix.com
netwrix.com › home › resources › blog › powershell environment variables
PowerShell Environment Variables
🌐
Marc Nuri
blog.marcnuri.com › home › windows: how to list all environment variables
Windows: How to list all environment variables - Marc Nuri
October 29, 2023 - The command outputs a list of all the environment variable names and values in a table format. A screenshot showing the output of the PowerShell Get-ChildItem Env: command
🌐
PowerShell Test-Path
powershellfaqs.com › list-all-environment-variables-in-powershell
How to List All Environment Variables in PowerShell?
November 20, 2024 - PS C:\> Get-ChildItem Env: | Where-Object { $_.Name -eq 'PATH' } Name Value ---- ----- PATH C:\Windows\system32;C:\Windows;C:\Program Files\Git\cmd;C:\Program Files\nodejs · In addition to listing environment variables, PowerShell allows you to create, modify, and remove them.
🌐
Netwrix
netwrix.com › home › resources › blog › powershell environment variables
PowerShell Environment Variables
August 25, 2025 - For instance, the PATH variable, ... straightforward methods to list all environment variables is by using the Get-ChildItem cmdlet with the “Env:” drive....
Find elsewhere
🌐
ShellGeek
shellgeek.com › home › powershell › powershell print environment variables
PowerShell Print Environment Variables - ShellGeek
April 14, 2024 - The above Get-ChildItem Env: command in PowerShell, print all environment variables. Sort cmdlet takes the output of the Get-ChildItem command and sorts the list of PowerShell environment variables by the variable name.
🌐
SharePoint Diary
sharepointdiary.com › sharepoint diary › powershell › how to get environment variables in powershell?
How to Get Environment Variables in PowerShell? - SharePoint Diary
September 20, 2025 - User scope applies to your account and persists across sessions without admin rights. Machine scope is system-wide for all users but needs admin privileges. Check scopes when listing with [Environment]::GetEnvironmentVariables("Machine") for machine-level ones. Are environment variables case-sensitive in PowerShell? On Windows, no.
🌐
TheITBros
theitbros.com › home › windows › managing environment variables in windows with powershell
How to Manage Windows Environment Variables with PowerShell
January 7, 2026 - Process scope – such environment variables are only available within the current process (PowerShell session). You can list them using the command: Get-Variable
🌐
Codecademy
codecademy.com › docs › powershell › environment variables
PowerShell | Environment Variables | Codecademy
May 16, 2023 - Jump into PowerShell through interactive lessons on variables, operators, control flow, objects, arrays, and functions. ... Running the Get-ChildItem cmdlet on the Env: drive lists all the environment variables defined in the current environment.
🌐
ShellHacks
shellhacks.com › home › windows: list environment variables – cmd & powershell
Windows: List Environment Variables - CMD & PowerShell - ShellHacks
December 3, 2019 - In this note i am showing how to list environment variables and display their values from the Windows command-line prompt and from the PowerShell.
🌐
Delft Stack
delftstack.com › home › howto › powershell › print environment variables in powershell
How to Print Environment Variables in Windows PowerShell | Delft Stack
February 12, 2024 - ... For a comprehensive overview of all environment variables, we employ the Get-ChildItem cmdlet. This command lists all the environment variables available in your PowerShell session.
🌐
Reddit
reddit.com › r/powershell › how to print all environment variables by scope? e.g. process, machine and user
r/PowerShell on Reddit: How to print all environment variables by scope? e.g. Process, Machine and User
March 28, 2019 -

Is there a way to print all environment variables by scope? Ideally I want to be able to create a cmdlet like the following

  • PrintEnvVariables -Scope Machine

  • PrintEnvVariables -Scope User

  • PrintEnvVariables -Scope Process

This is how I'm setting the environment variables at the moment

Process level

$env:procVar = 'some proc var' 

User level

[System.Environment]::SetEnvironmentVariable('myUserVar', 'some user val', [System.EnvironmentVariableTarget]::User)

Machine Level

[System.Environment]::SetEnvironmentVariable('myMachvar', 'some mach val', [System.EnvironmentVariableTarget]::Machine)

Now I know I can do something like

gci env:

But this just dumps all environment variables from all scopes. I even tried

gci env: | select * 

To see if there is any members I can filter by but there doesn't seem to be anything

PSPath        : Microsoft.PowerShell.Core\Environment::myUserVar
PSDrive       : Env
PSProvider    : Microsoft.PowerShell.Core\Environment
PSIsContainer : False
Name          : myUserVar
Key           : myUserVar
Value         : some user val

🌐
Michael Smith
mikesmith.us › home › technology › operating system › windows › windows 10 › comprehensive list of environment variables in windows 10/11
Comprehensive List of Environment Variables in Windows 10/11 - Michael Smith
October 3, 2022 - After launching Windows PowerShell, type in the command: Get-ChildItem Env:. This will display the list of Environment Variables. To sort the list you can use the command: Get-ChildItem Env: | Sort Name.
🌐
SysAdminSage
sysadminsage.com › home › blog › how to list environment variables in windows powershell
How to List Environment Variables in Windows PowerShell - SysAdminSage
1 week ago - Learn how to list environment variables in Windows PowerShell. Discover how to view, filter, and export variables across process, user, and machine scopes.
🌐
GitHub
github.com › fleschutz › PowerShell › blob › main › scripts › list-environment-variables.ps1
PowerShell/scripts/list-environment-variables.ps1 at main · fleschutz/PowerShell
Lists all environment variables · .DESCRIPTION · This PowerShell script lists all environment variables. .EXAMPLE · PS> ./list-environment-variables.ps1 · · Name Value · ---- ----- ALLUSERSPROFILE C:\ProgramData ·
Author   fleschutz
🌐
SS64
ss64.com › ps › syntax-env.html
Windows Environment variables in PowerShell
$windows_path = $env:Path $windows_path -split ';' PSModulePath lists all the paths that PowerShell searches for modules and includes in its module auto-loading: ... You can also change environment variables with Set-Item, Remove-Item, and Copy-Item.
🌐
Dotnet Helpers
dotnet-helpers.com › home › powershell › work with environment variables using windows powershell – part i
Work with Environment Variables using Windows PowerShell | Dotnet Helpers
December 2, 2020 - We access environment variables using the built-in variable called $env followed by a colon and the name of the environment variable. The $env variable can be used to access all user context environment variables.
🌐
TutorialsPoint
tutorialspoint.com › article › how-to-get-environment-variable-value-using-powershell
How to get environment variable value using PowerShell?
October 31, 2023 - You can also use dir env: command to retrieve all environment variables and values. To retrieve a specific environment variable, provide variable name after env: PS C:\Windows\system32> Get-ChildItem -Path Env:\SystemDrive Name Value ---- ----- ...