Skip to content

Instantly share code, notes, and snippets.

@sevenc-nanashi
Last active May 20, 2021 13:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sevenc-nanashi/5a4b44161f3f7b6ce991a177188ff7a8 to your computer and use it in GitHub Desktop.
Save sevenc-nanashi/5a4b44161f3f7b6ce991a177188ff7a8 to your computer and use it in GitHub Desktop.
Param($file = ".env")
$DB = Get-Content $file
$Count = 0
foreach ($Data in $DB) {
$Count += 1
Invoke-Expression ([regex]::Replace($Data,"^([^=]+)=""?([^=]+)""?$",{"`$env:" + $args.groups[1].value + "=""" + $args.groups[2].value + """"},[System.Text.RegularExpressions.RegexOptions]::Multiline))
}
write-host "Loaded " -NoNewline
write-host $Count -NoNewline -ForegroundColor Cyan
write-host " Variables."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment