If sometime during a PowerShell session you need to see or to temporarily modify the PATH environment variable, you can type one of these commands:

$env:Path                             # shows the actual content
$env:Path = 'C:\foo;' + $env:Path     # attach to the beginning
$env:Path += ';C:\foo'                # attach to the end
Answer from mloskot on Stack Overflow
🌐
Microsoft Learn
learn.microsoft.com › en-us › powershell › module › microsoft.powershell.core › about › about_environment_variables
about_Environment_Variables - PowerShell | Microsoft Learn
To change values in the Machine or User scopes, you must use the methods of the System.Environment class. To make changes to Machine-scoped variables, you must also have permission. If you try to change a value without sufficient permission, the command fails and PowerShell displays an error.
Discussions

Change Environment Path and MAKE IT STICK
See https://www.reddit.com/r/PowerShell/comments/1c4ds4x/comment/kzn7au6/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button as to why you shouldn't use SetEnvironmentVariable for PATH like env vars. The reason why this isn't working is because SetEnvironmentVariable defaults to the process scoped env vars so this is the same as doing $env:PATH = "new value". You can call the overload where you set the Machine scoped vars but see my above comment as to why you don't use to use that. Also as mentioned by u/BlackV entries in the C:\Program Files\WindowsApps folder should not be on the PATH directly. These entries are installed per user which then adds an App Execution Alias in %LOCALAPPDATA%\Microsoft\WindowsApps which is in the user's `PATH` scoped envvar. You should be ensuring that winget is installed for that user and provisioned as part of the default user profile so new user profiles will get it by default. More on reddit.com
🌐 r/PowerShell
11
5
April 15, 2024
How can I get and change environment variables' value in Windows Powershell
Discussed in #9473 Originally posted by xiaolinggnb August 16, 2024 I'm using Windows 11 and willing to get the environment variable value of gh and change them in Windows Powershell, which are lis... More on github.com
🌐 github.com
1
1
Set a persistent environment variable on a windows 10 computer with PowerShell?
Check out this method: https://docs.microsoft.com/en-us/dotnet/api/system.environment.setenvironmentvariable?view=net-6.0#system-environment-setenvironmentvariable(system-string-system-string-system-environmentvariabletarget) More on reddit.com
🌐 r/PowerShell
12
3
February 3, 2022
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
People also ask

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 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 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
🌐
Netwrix
netwrix.com › home › resources › blog › powershell environment variables
PowerShell Environment Variables
August 25, 2025 - PowerShell environment variables ... and scripts. They can be listed with Get-ChildItem Env:, accessed with $Env: , modified with Set-Item or [Environment]::SetEnvironmentVariable(), and removed with Remove-Item....
🌐
Reddit
reddit.com › r/powershell › change environment path and make it stick
r/PowerShell on Reddit: Change Environment Path and MAKE IT STICK
April 15, 2024 -

Hi all,

We've got an odd issue where random machines (all Win11) cannot run Winget, even though it's installed. I've identified the cause as being Winget isn't included in the PATH environment variable. Now I've got a script written for this (as an Intune Remediation), but in testing this won't stick.

Found an article about setting this to the Machine context, but not sure if I'm doing it right because it still won't goddamned stick. Script below - can anyone assist with this?

# Get winget path into variable
$wingetPath = Resolve-Path "C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_*_x64__8wekyb3d8bbwe"
 # Extract PATH into separate values
$pathParts = $env:PATH -split ';'
# Append winget path to PATH values
$addToPath = $pathParts + $wingetPath | Where-Object { $_ }
# Reconstitute and set PATH with new variables
$newEnvPath = $addToPath -join ';'
[System.Environment]::SetEnvironmentVariable('PATH',$newEnvPath)

🌐
GARYTOWN
garytown.com › edit-add-remove-system-path-variable-via-powershell
Edit (Add / Remove) System Path Variable via PowerShell – GARYTOWN ConfigMgr Blog
August 22, 2019 - #GARYTOWN.COM @gwblok #Script to Add and/or remove items from the System Path #Get Current Path $Environment = [System.Environment]::GetEnvironmentVariable("Path", "Machine") #Remove "Junk" from Path foreach ($path in ($Environment).Split(";")) { if ($path -like "*SysWOW64\WIndowsPowerShell\v1.0*") { $Environment = $Environment.Replace($Path ,"") } if ($path -like "c:\temp*") { $Environment = $Environment.Replace($Path ,"") } } #Add Items to Environment $AddPathItems = "C:\Windows\CCM\;C:\ProgramData\WaaS\;" $Environment = $Environment.Insert($Environment.Length,$AddPathItems) #Set Updated Path [System.Environment]::SetEnvironmentVariable("Path", $Environment, "Machine")
Find elsewhere
🌐
O'Reilly
oreilly.com › library › view › professional-windows-r-powershell › 9780471946939 › 9780471946939_modifying_environment_variables.html
Modifying Environment Variables - Professional Windows® PowerShell [Book]
April 23, 2007 - 21.4. Modifying Environment Variables You can modify environment variables but only for the duration of a Windows PowerShell session. The following example adds a new directory C:\... - Selection from Professional Windows® PowerShell [Book]
Author   Andrew Watt
Published   2007
Pages   551
🌐
GitHub
github.com › cli › cli › discussions › 9475
How can I get and change environment variables' value in Windows Powershell · cli/cli · Discussion #9475
If you'd like the variable to be more permanent, you should add it to your .bashrc, .bash_profile, or similar so it gets exported every time you start a new shell session. Here's some Microsoft documentation about managing environment variables on Windows, if that's the environment you are using.
Author   cli
🌐
Codecademy
codecademy.com › docs › powershell › environment variables
PowerShell | Environment Variables | Codecademy
May 16, 2023 - Environment variables store information related to the current environment like the Operating System and user sessions. These global variables are name-value pairs that can be accessed across commands and programs. ... Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more! ... Jump into PowerShell through interactive lessons on variables, operators, control flow, objects, arrays, and functions.
🌐
GitHub
gist.github.com › refactorsaurusrex › 4cce03f6fe714db533d6c7bcb5a57444
How to open the Windows environment variables dialog with PowerShell · GitHub
It takes waaaay too many clicks to open the Windows environment variables dialog. Wouldn't it be nicer to open it with a quick cli command? Copy the code from profile.ps1 to your PowerShell profile script. Change the alias to your preferred value. ... Thanks to this guy for sharing the command that does the magic! ... This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor ...
🌐
SPGuides
spguides.com › set-environment-variables-using-powershell
How to Set Environment Variables Using PowerShell
January 18, 2024 - To set an environment variable in PowerShell, you can use the Set-Item cmdlet.
🌐
Serverwala
serverwala.com › home › how to set environment variables with powershell?
How to Set Environment Variables with Powershell?
June 5, 2024 - Using the Get-ChildItem Cmdlet: This is another method to list all the environment variables in the current session. In PowerShell, you can set environment variables temporarily using the “$env” and “set-item” commands.
🌐
YouTube
youtube.com › watch
How to set an Environment Variable in Powershell
Enjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube.
🌐
Codingbee
codingbee.net › powershell › powershell-make-a-permanent-change-to-the-path-environment-variable
Powershell – Make a permanent change to the “path” environment variable
October 18, 2014 - A common task you often need to do is append a new path to the path environment variable: Announcement You can find all my latest posts on medium. $ENV:PATH The first way is simply to do: $ENV:PATH="$ENV:PATH;c:\path\to\folder" But this change isn’t permenant, $env:path will default back to what it was before as soon as you […]
🌐
TechExpert
techexpert.tips › home › powershell
Tutorial Powershell - Edit the PATH environment variable [ Step by step ]
March 1, 2026 - Create a temporary Powershell variable named INCLUDE. Set its content to the directory that you want to include on the PATH variable. ... In our example, we want to include the following directory in the PATH environment variable.
Top answer
1 of 9
179

Note: After seeing lots of comments about setting environment variables without administrator rights in Windows 10, I think I have found a way. I was not administrator and could use PowerShell.

PowerShell method

You can list all environment variables with: Get-ChildItem Env:.

To get the value of a specific variable: $Env:PATH, where PATH is the name of the variable.

To set a variable: [Environment]::SetEnvironmentVariable("PATH", "C:\TestPath", "User"), the first parameter is the name of the variable, the second is the value, the third is the level of.

There are different ways to work with environment variables and certain quirks with them in PowerShell so consult the link for details.

Old method (no longer available in newer Windows 10 updates, use PowerShell or see other answers)

Go into Settings and click on System.

Then on the left side click About and select System info at the bottom.

In the new Control Panel window that opens, click Advanced system settings on the left.

Now in the new window that comes up, select Environment Variables... at the bottom.

2 of 9
127

Still the same as ever: It’s in the old-style control panel’s “System” thingy. You can reach it with WinBreak or by right-clicking the Start button.

From there, select “Advanced system settings” → “Environment Variables”.

Or you can do it the hard way and find some other entry point to the old-style control panel, like the Network and Sharing Center or the Desktop folder(!).