mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2024-11-14 14:45:52 -06:00
18 lines
563 B
Plaintext
18 lines
563 B
Plaintext
|
<#
|
||
|
|
||
|
.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)" }
|
||
|
}
|
||
|
}
|