Thursday, 9 June 2016

Setting Windows PowerShell path variable

Hello Folks,

To find the current environment PATH variable use the following cmdlet.

$env:Path



Some time during a PowerShell session, you need to modify the PATH environment variable temporarily, you can do it this way.



$env:Path = $env:Path + ";C:\java\bin"

$env:Path = $env:Path + ";C:\java\lib"



Or a much easier way is as below.


$env:Path += ";C:\java\lib" or $env:Path += ";C:\java\bin"



Please note the ";"  before the path, this is necessary so that the path would have

the right syntax and wouldn't break anything.


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.

No comments:

Post a Comment