Shorter version:

gci env:* | sort-object name

This will display both the name and value.

Answer from jaymjarri on Stack Overflow
🌐
Microsoft
devblogs.microsoft.com › dev blogs › scripting blog [archived] › powertip: use windows powershell to display all environment variables
PowerTip: Use Windows PowerShell to display all Environment variables - Scripting Blog [archived]
January 15, 2020 - When PowerShell is locked down in safe mode, you are not allowed to call methods on object for security reasons, so using System.Environment is out of the question then. The right way to get to environment variables in PowerShell is the Env: PSDrive.
Discussions

PowerShell command to add the environment variable
I want to add below 2 environment variables using PowerShell command. I have done it manually but now and down the line I want to add environment variables in VM using PowerShell commands, Please suggest More on learn.microsoft.com
🌐 learn.microsoft.com
2
0
February 3, 2024
PowerShell command to list all the environment variables of virtual machine
Is there any PowerShell command to list all the environment variables available in Virtual machine and export to CSV file More on learn.microsoft.com
🌐 learn.microsoft.com
1
0
February 9, 2024
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
🌐
Netwrix
netwrix.com › en › resources › blog › powershell-environment-variables
PowerShell Environment Variables
August 25, 2025 - PowerShell environment variables store system and user configuration as key-value pairs accessible across processes and scripts. They can be listed with Get-ChildItem Env:, accessed with $Env: , modified with Set-Item or [Environment]::SetE...
🌐
PowerShell Test-Path
powershellfaqs.com › set-and-get-environment-variables-in-powershell
How to Set and Get Environment Variables in PowerShell?
September 4, 2024 - To set an environment variable in PowerShell, you can simply use the $env variable followed by the variable name and assign it a value. For example, to set the variable “MyVariable” to “Hello, World!”, you would use the command $env:MyVariable = "Hello, World!".
🌐
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.
Find elsewhere
🌐
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.
🌐
PowerShell Gallery
powershellgallery.com › packages › xEnvironmentVariables › 0.1.5 › Content › Public\Get-EnvironmentVariable.ps1
PowerShell Gallery | Public/Get-EnvironmentVariable.ps1 0.1.5
xEnvironmentVariables · 0.1.5 · Public/Get-EnvironmentVariable.ps1 · Contact Us · Terms of Use · Gallery Status · Feedback · © 2026 Microsoft Corporation
🌐
GitHub
gist.github.com › RebeccaWhit3 › 5dad8627b8227142e1bea432db3f8824
Complete List of Environment Variables in Windows 10 · GitHub
User environment variables are stored in the registry key below: ... You can open a Command Prompt, type set, and press Enter to display all current environment variables on your PC. You can open PowerShell, type Get-ChildItem Env:, and press Enter ...
🌐
SharePoint Diary
sharepointdiary.com › sharepoint diary › powershell › how to set environment variables in powershell?
How to Set Environment Variables in PowerShell? - SharePoint Diary
October 7, 2025 - To view all environment variables in PowerShell, you can use the Get-ChildItem cmdlet on the Env: drive like this: “Get-ChildItem Env:”. This command lists all environment variables available in your session.
🌐
Computer Performance
computerperformance.co.uk › home › powershell
PowerShell Basics: $Env: - Environment Variables | Examples & Scripts
January 16, 2019 - Once you know that Env is a drive, then you can list its variables and their values. This is just like you would use PowerShell to list the folders and files in the C: drive. # List PowerShell's Environmental Variables Get-Childitem -Path Env:* | Sort-Object Name
🌐
Java2Blog
java2blog.com › home › powershell › print environment variables in powershell
Print Environment Variables in PowerShell - Java2Blog
November 27, 2022 - In this tutorial, you will learn different methods to print environment variables using PowerShell.
🌐
Microsoft
devblogs.microsoft.com › dev blogs › scripting blog [archived] › powertip: use powershell to display windows path
PowerTip: Use PowerShell to Display Windows Path - Scripting Blog [archived]
June 7, 2014 - How can I use Windows PowerShell to inspect my Windows path to see what folders are there and in what order they appear? Use the $env PS Drive and retrieve the value of the Path variable. By default, it displays as a continuous string, […]
🌐
Leeholmes
leeholmes.com › accessing-environment-variables-in-powershell
Lee Holmes | Accessing Environment Variables in PowerShell
May 10, 2006 - This is because the Environment provider shares something in common with several other providers – namely support for the *-Content set of core Cmdlets: [C:\temp] PS:11 > "hello world" > test [C:\temp] PS:12 > get-content test hello world [C:\temp] PS:13 > get-content variable:ErrorActionPreference Continue [C:\temp] PS:14 > get-content function:more param([string[]]$paths); if(($paths -ne $null) -and ($paths.length -ne 0)) { ...
🌐
Configu
configu.com › home › setting environment variables in powershell: a practical guide
Setting Environment Variables in PowerShell: A Practical Guide - Configu
January 17, 2025 - This command is similar to the full list retrieval, but retrieves only one value, making it ideal for quick checks on specific settings: # Retrieve a specific environment variable value [System.Environment]::GetEnvironmentVariable('ranker_api_url') These methods provide flexibility, enabling you to efficiently retrieve detailed or targeted environment information as needed. Setting or modifying environment variables in PowerShell ...
🌐
Medium
kevinlinxc.medium.com › viewing-and-setting-environment-variables-in-every-shell-4df43127bd8
Viewing and Setting Environment Variables in Every Shell | by Kevin Lin | Medium
September 11, 2023 - Windows Powershell · Windows Command Prompt · Bash/Git Bash/Zsh · # list all environment variables ls env: # fetch a specific environment variable $env:VariableName # pretty print the PATH variable (one path per line) $env:PATH -split ';' ...
🌐
Microsoft Learn
learn.microsoft.com › en-us › powershell › module › microsoft.powershell.core › about › about_environment_variables
about_Environment_Variables - PowerShell | Microsoft Learn
Use the Get-ChildItem cmdlet to see a full list of environment variables: ... Beginning in PowerShell 7.5, you can set an environment variable to an empty string using the environment provider and Set-Item cmdlet.
🌐
ITPro Today
itprotoday.com › home › powershell
Environment Variables in PowerShell
November 29, 2024 - It does this by running Cmd.exe to execute the shell script followed by the Set command, which outputs a list of all environment variables and values. The function parses the shell script's output using a regular expression and uses the Set-Item cmdlet to set each environment variable in PowerShell.
🌐
Microsoft Learn
learn.microsoft.com › en-us › answers › questions › 1528513 › powershell-command-to-list-all-the-environment-var
PowerShell command to list all the environment variables of virtual machine - Microsoft Q&A
February 9, 2024 - Hi Deherman, In VM, When we navigate to start button and look for environment variables , we can all system variables and user variables list right?