generate yaml file from envrionement variable in Windows

Issue

I would export environement variable seted in Windows to yaml file

any tips to do that ?

Solution

You can use PowerShell. This requires

Install-Module powershell-yaml

Then you can do

Import-Module powershell-yaml
$vars = @{}
Foreach ($v in Get-Item -Path Env:*) {
    $vars[$v.Key] = $v.Value
}
ConvertTo-Yaml $vars

We need to generate $vars because Get-Item returns an array of DictionaryEntries. I’m unsure whether there’s a better way to get a hashtable of env vars.

Answered By – flyx

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published