This PowerShell blog post will show how to create a temporary environment variable on Windows using Powershell.
Creating environment variables is very handy when developing applications or when in need of running apps and scripts. The most common use of environment variables saves information like endpoints, access keys and more.
A temporary environment variable is only available for the session and won’t be available after the session is closed (terminal or computer restart).
Create an Environment Variable
To create an environment variable using PowerShell, run the following command.
$env:MY_VARIABLE = "MyValue"
To list all the environment variables on your machine, run
Get-ChildItem Env:
To create a permanent environment variable, use the following command.
[Environment]::SetEnvironmentVariable("MY_VARIABLE", "MyValue", "Machine")
Leave a Reply