问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/27109319/powershell-and-cmd-environment-variables