Home > other >  How do I read a .env file from a .ps1 script?
How do I read a .env file from a .ps1 script?

Time:05-15

I have a .env file like this one:

TESTCASE_GROUP_SIZE=25
. . .

And I want to get its value (read it) into a .ps1 script. How can I do it?

CodePudding user response:

get-content test.env | foreach {
    $name, $value = $_.split('=')
    set-content env:\$name $value
}

assuming you mean "set one environment variable per line in the file".

  • Related