Windows Path environment variable is used to locate binaries, libraries, and software to load or execute. The Path variable simply provides multiple paths. The Paths environment variable contains multiple paths by separating them with semicolon ;
. PowerShell can be used to access, update, and manage the Windows Path environment variable.
Display Path Environment Variable
The PowerShell provides the $Env
in order to access environmet variables. We can use the $Env in order to access Path environment variable. The $Env:Path
is used to display Path environment variable.
PS> $Env:Path
C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\ismail\AppData\Local\Microsoft\WindowsApps;
From the output we can see that there are multiple paths. These multiple paths are separated with ; sign.
Add New Path To Environment Variable
We can add a new Path to the existing Path environment variable. The String -join
operation can be used like below. In the following example we add the new path “d:/binary” to the existing Path environment variable.
PS> $env:Path = ($env:Path + $addPath) -join ';'