diff --git a/scripts/Windows/export-environment-file.ps1 b/scripts/Windows/export-environment-file.ps1 index c384c7d3..41f88480 100644 --- a/scripts/Windows/export-environment-file.ps1 +++ b/scripts/Windows/export-environment-file.ps1 @@ -10,13 +10,14 @@ if (-not (Test-Path $envFile)) exit 1 } +$envVars = @{ } + Get-Content $envFile | ForEach-Object { $line = $_.Trim() if ($line -eq '' -or $line.StartsWith('#')) { return } - if ($line -notmatch '=') { return @@ -37,9 +38,14 @@ Get-Content $envFile | ForEach-Object { $value = $value.Substring(1, $value.Length - 2) } - New-Item -Path Env:\$key -Value $value - - Write-Host "Set environment variable: $key" + New-Item -Path Env:\$key -Value $value | Out-Null + $envVars[$key] = $value } -Write-Host "All variables loaded from $envFile." +if ($envVars.Count -gt 0) +{ + $formatted = ($envVars.GetEnumerator() | Sort-Object Name | ForEach-Object { + "$( $_.Key )=$( $_.Value )" + }) -join ';' + Write-Host $formatted +} \ No newline at end of file