Updating Path in PowerShell

To view the path in the PowerShell.

$env:Path

This will display a long string, where each path element is separated by semicolon characters (;).  Also, a lowercase p works for path.

To add to the path, you can do the following:

$env:Path += ";C:\Some\Different\Path"

The semicolon at the start of the string is important, so that it separates this path element from any other path element before it.

To remove an item from the path, you need to parse the string and remove the path element. This can be done with the following:

$Remove = "C:\A\Path\That\I\Want\To\Remove"
$env:Path = ($env:Path.Split(';') | Where-Object -FilterScript {$_ -ne $Remove}) -join ';'

The above will split the path into a list of items, without the semicolons. A filter is then applied that selects items that do not match the string that you want to remove. The remaining items are then combined together into a single string that has semicolons to separate the items. That string is assigned to the path, replacing what was there before.

The Remove example, comes from a Stack Overflow answer.