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.

2
  • 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 '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
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.