How do I make foo an environment variable accessible through printenv on bash?

PS /home/thufir/powershell/helloPSTwitterAPI> 
PS /home/thufir/powershell/helloPSTwitterAPI> $env:foo = 'x' * 333 + '!'      
PS /home/thufir/powershell/helloPSTwitterAPI> 
PS /home/thufir/powershell/helloPSTwitterAPI> $env:foo
PS /home/thufir/powershell/helloPSTwitterAPI> 

I would like to use powershell to set an environment variable rather than using setenv itself so that Visual Studio Code, and bash, will pick up the variables when running powershell scripts.

  • 1
    PowerShell may be case sensitive, as is implied in docs.microsoft.com/en-us/powershell/module/… . What happens when you use Env instead of env ?
    – K7AAY
    Jan 23, 2020 at 19:54
  • Nope. I'm fairly sure it's doable, just don't know how. Thanks, though, @K7AAY
    – Thufir
    Jan 23, 2020 at 20:41

1 Answer 1


I would do it as described below:


See also

This way the environment variable (in this case DOCKER_HOST) is created permanently as if you would've created it via the windows control panel.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .