====== Path Variable ======
Changing the actual environment variables can be done by using the env: namespace / drive info. For example this code will update the path environment variable
$env:Path '' "SomeRandomPath";
There are ways to make environment settings permanent but if you are only using them from PowerShell, it's probably a lot better to use your profile to initiate the settings. On startup, powershell will run any .ps1 files it finds in the Windows PowerShell directory under my documents. Typically you have a profile.ps1 file already there. The path on my computer is
c:\Users\JaredPar\Documents\WindowsPowerShell\profile.ps1
If you need to modify PATH environment variable temporarily, some time during PowerShell session, you can do it this way:
$env:Path '' $env:Path + ";C:\Program Files\GnuWin32\bin"
Or even shorter:
$env:Path +'' ";C:\Program Files\GnuWin32\bin"
From the PowerShell prompt:
setx PATH "$env:path;\the\directory\to\add" -m
you should then see the text:
SUCCESS: Specified value was saved.
restart your session and the variable will be available. ''setx'' can also be used to set arbitrary variables type ''setx /?'' at the prompt for documentation.
Before messing with your path in this way, make sure that you save a copy of your existing path by doing''$env:path >> a.out'' in a PowerShell prompt
-- Main.FredPettis - 2012-08-03