1

I use a batch script to set some environment variables local to that shell. When I launch PowerShell from that command prompt, I was expecting those environment variables to be available in the PowerShell script. But I don't see that happening.

Can someone help me what I'm missing?

2
  • 2
    Where is your code? Can't help you if we can't see the code! Commented Nov 24, 2014 at 16:23
  • I was trying with '.' Keith's suggestion helped.. Commented Nov 24, 2014 at 16:46

2 Answers 2

7

Those environment variables should be there in PowerShell but you have to access them using the Environment provider e.g.:

$env:foo

where foo is the environment variable name.

Sign up to request clarification or add additional context in comments.

1 Comment

Ooops.. I was trying with '.' ($env.foo) Thanks Keith.
0

I have a similar issue where I'm setting an environment variable "SETX FOO BAR /M" where BAR is the result of a query. While I see the new/updated FOO variable correctly in the System Properties --> Environment Variables window under System Variables, I do not get the correct value under Powershell "$Env:FOO" or DOS Command Prompt with "SET FOO". I was expecting that all environment variables would be set the same across the board. I want to be able to query this variable as %FOO% in a GPO for setting up delegation.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.