Skip to content

Instantly share code, notes, and snippets.

@bill-long
Created December 28, 2014 17:15
Show Gist options
  • Save bill-long/230830312b70742321e0 to your computer and use it in GitHub Desktop.
Save bill-long/230830312b70742321e0 to your computer and use it in GitHub Desktop.
foreach($level in "Machine","User") {
[Environment]::GetEnvironmentVariables($level).GetEnumerator() | % {
# For Path variables, append the new values, if they're not already in there
if($_.Name -match 'Path$') {
$_.Value = ($((Get-Content "Env:$($_.Name)") + ";$($_.Value)") -split ';' | Select -unique) -join ';'
}
$_
} | Set-Content -Path { "Env:$($_.Name)" }
}
@bergmeister
Copy link

Thanks. This helped me resolve an issue where I have to install an MSI inside an AppVeyor build and therefore had to refresh the path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment