diff --git a/profile.d/SystemName.class.ps1 b/profile.d/SystemName.class.ps1 index 022340f..8ce740f 100644 --- a/profile.d/SystemName.class.ps1 +++ b/profile.d/SystemName.class.ps1 @@ -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" } diff --git a/sys.Linux/Set-EnvVariable.ps1 b/sys.Linux/Set-EnvVariable.ps1 new file mode 100644 index 0000000..a51daa7 --- /dev/null +++ b/sys.Linux/Set-EnvVariable.ps1 @@ -0,0 +1,6 @@ +[CmdletBinding()]param( + [string]$Name, + [object]$Value +) + +Set-Item -Path (Join-Path "env:" $Name) -Value $Value diff --git a/sys.Windows/Set-EnvVariable.ps1 b/sys.Windows/Set-EnvVariable.ps1 new file mode 100644 index 0000000..5de891d --- /dev/null +++ b/sys.Windows/Set-EnvVariable.ps1 @@ -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) +} \ No newline at end of file