Set-EnvVariable + minor fix to SystemName

This commit is contained in:
lksz@work 2020-11-24 13:15:47 -05:00
parent 25ec753675
commit 80a488484b
3 changed files with 18 additions and 0 deletions

View File

@ -18,6 +18,7 @@ class SystemName { #: System.Management.Automation.IValidateSetValuesGenerator {
}
$possibleValues.out = $possibleValues.out |
Select-Object -Unique |
Where-Object { $_ } |
Sort-Object {
$local:sortName = "zz_$_";
if( $_ -in $possibleValues.Exist -and $_ -in $possibleValues.Current ) { $sortName[0] = "a" }

View File

@ -0,0 +1,6 @@
[CmdletBinding()]param(
[string]$Name,
[object]$Value
)
Set-Item -Path (Join-Path "env:" $Name) -Value $Value

View File

@ -0,0 +1,11 @@
[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)
}