Last active
June 5, 2019 23:34
-
-
Save jwatney/c00ac732f2d3ebec58801e7ff17a8408 to your computer and use it in GitHub Desktop.
Writes env vars matching a prefix to a file. E.g. `write-env-vars.ps1 -Prefix MYAPP_ -Path Environment.config` Useful if you want env vars from your build system to be available to your deployed app.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param([String] $prefix, [String] $path) | |
# Write-Out environment variables to file. | |
Get-ChildItem env:* | Where-Object Name -Like "$($prefix)*" | ForEach-Object { | |
$name = $_.Name.Replace("_", ".") | |
$key = $name -Replace ":([\d]+):", "[`${1}]" | |
Write-Output "$key=$($_.Value)" | |
} | Out-File -FilePath $path |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Goes well with this: https://gist.github.com/jwatney/b7bdfd124f299d5e616716ec700951cf