mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-12-17 17:55:28 +00: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)" }
|
||
|
|
}
|
||
|
|
}
|