function Import-DeployDotEnv { param([string]$Path) if (-not (Test-Path $Path)) { return } Get-Content $Path | ForEach-Object { if ($_ -match '^\s*#' -or $_ -match '^\s*$') { return } if ($_ -match '^([A-Za-z_][A-Za-z0-9_]*)=(.*)$') { $name = $Matches[1]; $raw = $Matches[2].Trim() $v = $raw if ($raw.StartsWith("'") -and $raw.EndsWith("'")) { $v = $raw.Trim("'") } elseif ($raw.StartsWith('"') -and $raw.EndsWith('"')) { $v = $raw.Trim('"') } [Environment]::SetEnvironmentVariable($name, $v, "Process") } } }