You can easily set an environment variable from a command prompt using the setx.exe command included in Windows since Vista. In addition to environment variables, PowerShell providers also provide access to other data and components in a similar way - resembling a file system drive. You can use it to easily set a user variable: >setx ASPNETCORE_ENVIRONMENT "Development" SUCCESS: Specified value was saved. This allows you to access many different types of data in a consistent way.
Note that the environment variable is not set in the current open window.
How do I change the environment variables for PowerShell (v1)? Note: I want to make my changes permanent, so I don't have to set it every time I run PowerShell. Problem Changing Environment Variable Values with PowerShell. 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. View and Set Windows Environment Variables via the GUI. PowerShell seems to have different environment settings. In this note i am showing how to set an environment variable in Windows from the command-line prompt (CMD) and from the Windows PowerShell. You will need to open a new command prompt to see the updated environment. The right way to get to environment variables in PowerShell is the Env: PSDrive. To see a GUI view of the user and system environment variables, run SystemPropertiesAdvanced.exe from PowerShell, a command prompt or from Windows Key+R to display the System Properties Advanced tab. An environment variable is a dynamic “object” containing an editable value which may be used by one or more software programs in Windows. Click on the EnvironmentVariables button, which is highlighted in the image below. When you change the value of an environment variable using PowerShell commands, the changes only affect the current session. The requested “set” equivalent would just be “dir env:”. The new PowerShell System environment variable is visible: It’s quite interesting that the PowerShell environment variables are stored in a drive, which you can access using: Set-Location Env: Get-ChildItem. PowerShell’s Env Drive Think of Env: as a drive, it’s just like the C:, except Env: contains not folders but variables such as ‘Path’ or ‘Windir’. Let's see how we can manage environment variables with PowerShell.
The Environment Provider PowerShell has a feature called providers that creates one or more drives, which are hierarchical, file system-like structures that allow a user to manage various areas in Windows.
This behavior mimics using the Set command of previous Windows operating systems. I have found out that setting the PATH environment variable affects only the old command prompt. Set-Location Env: Get-ChildItem. Set-Location Env: Get-ChildItem.