Skip to content

Instantly share code, notes, and snippets.

@patrickhuber
Last active January 14, 2016 16:11
Show Gist options
  • Save patrickhuber/cc7614dc797b028bcb01 to your computer and use it in GitHub Desktop.
Save patrickhuber/cc7614dc797b028bcb01 to your computer and use it in GitHub Desktop.
$variables =
[Environment]::GetEnvironmentVariable("Path", [System.EnvironmentVariableTarget]::Machine) -split ';' |
foreach { $_.Trim().TrimEnd('\\') } |
group |
select -ExpandProperty Name |
where { -not [string]::IsNullOrWhitespace($_) }
$path = $variables -join ';'
[Environment]::SetEnvironmentVariable("PATH", $path, [System.EnvironmentVariableTarget]::Machine)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment