2

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
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx!
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.

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

1 Answers1

0

I would do it as described below:

[System.Environment]::SetEnvironmentVariable('DOCKER_HOST','docker.artofshell.com')

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.

Jonas
  • 544