I was skimming through the msdn blogs and saw this post
As I had the same problem a few months back when first starting using PowerShell I thought I’d post my solution to it here, as I think it is more general. It can take any bat file’s environment and hook into PowerShel
And it will work with all version of Visual Studio (at least those you might still use)
First the function I can call from any shell (32 or 64 bit) to get the environment for the proper version of VS.
And then the ugly but functional envbat function which can take any bat file and "steal" its environment and add it to psh.
So there you have it. A quick explanation, it first remember the current psh environment, runs the batch file followed by "set" (line 8) which produces a list of all environment variables from the cmd shell. Walks through and stores those that match the regexp. The rest is just a matter of updating the psh environment with the cmd keys.