Files
winutil/functions/private/Update-EnvironmentVariables
T

18 lines
563 B
Plaintext
Raw Normal View History

2023-07-27 16:06:41 -05:00
<#
.DESCRIPTION
Updates Path Variables for the current session
#>
function Update-EnvironmentVariables {
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-Object -unique) -join ';'
}
$_
} | Set-Content -Path { "Env:$($_.Name)" }
}
}