Skip to content

Instantly share code, notes, and snippets.

@manualbashing
Last active June 7, 2019 10:52
Show Gist options
  • Save manualbashing/bf53c33eb1c8a866a3b4 to your computer and use it in GitHub Desktop.
Save manualbashing/bf53c33eb1c8a866a3b4 to your computer and use it in GitHub Desktop.
Working with environment variables
$ENV:PATH = $ENV:PATH + ";C:\Windows\System32"
#See all environment variables
Get-ChildItem Env:
#Alternative using .NET:
[Environment]::GetEnvironmentVariables()
# Get the content of an individual variable:
$Env:USERPROFILE
#Alternative using .NET:
[Environment]::GetEnvironmentVariable("Userprofile", "Process")
#Set environment variable via .NET for the scopes Process, User, Machine
[Environment]::SetEnvironmentVariable("USERPROFILE", "C:\Users\Administrator", "Process")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment