Skip to content

Windows environment variables

Environment variables in Powershell

Session variables

Variables created by set are bound to the current session and not persistent.

$Env:FOO = "example"
$Env:FOO

Persistent variables

  • GUI: Windows Settings -> Advanced system settings -> Set Environment Variables.
  • Powershell: [Environment]::SetEnvironmentVariable('KEY', 'VAL', 'Machine')
  • Cmd: SETX KEY VAL

Comments