To Set the PATH environment variable in powershell , We can use following command
$env:Path = “anypath”;
To modify the PATH environment variable temporarily
$env:Path = $env:Path + “;C:scripts”
or
$env:Path += “;C:scripts”
Note: Before messing with your path in this way, make sure that you save a copy of your existing path which can be saved by running following$env:path >> a.out
in a PowerShell prompt.
You can also modify user/system environment variables permanently (i.e. will be persistent across shell restarts) with the following
### Modify system environment variable ###
[Environment]::SetEnvironmentVariable
( "Path", $env:Path, [System.EnvironmentVariableTarget]::Machine )
### Modify user environment variable ###
[Environment]::SetEnvironmentVariable
( "INCLUDE", $env:INCLUDE, [System.EnvironmentVariableTarget]::User )