PowerShell_Scripts/base.win/Set-EnvVariable.ps1

11 lines
254 B
PowerShell

[CmdletBinding()]param(
[string]$Name,
[object]$Value,
[ValidateSet('User','Machine')]
[string]$Persist
)
Set-Item -Path (Join-Path "env:" $Name) -Value $Value
if( $Persist ) {
[environment]::setEnvironmentVariable($Name, $Value, $Persist)
}