Skip to content

Instantly share code, notes, and snippets.

@kumarharsh
Last active June 18, 2021 17:05
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kumarharsh/96b36ae817b56df391071b310831b4a5 to your computer and use it in GitHub Desktop.
Save kumarharsh/96b36ae817b56df391071b310831b4a5 to your computer and use it in GitHub Desktop.
[Powershell] Update Environment Variable one-liner
# These snippets provide a quick way to update your environment variables
# directly from your powershell console. Just copy paste these lines, or
# even better, add it to your profile as functions.
# refreshing env in current shell
$env:path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
# adding path to env
# set path in the $_newPath variable, and it'll get set to your user environment path and persisted.
$_newPath=""; [System.Environment]::SetEnvironmentVariable("Path", [System.Environment]::GetEnvironmentVariable("Path", "User") + ";${_newPath}", "User")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment