Get PATH environment variable in PowerShell
Asked Answered
C

3

25

I want to check the PATH environment variable in PowerShell

I've tried

Get-ChildItem env:path

I want to get the complete path, but get only a very small part of it. How much I get depends on the width of the PowerShell window, e.g.

C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Progra...
Cacuminal answered 14/8, 2019 at 11:10 Comment(3)
$env:Path -replace ';', "`n"Corpsman
$env:Path alone will expand the list so you can read it all. However, the replacement with CrLf is very nice.Aerostation
Please consider selecting one of the answers as the solution to your question.Iodide
R
25

If want to see the full path, one method is to use echo:

echo $env:path
Rejoinder answered 16/9, 2022 at 19:11 Comment(1)
actually, there is no need for echo, you can just use :\>$env:pathAerostation
S
9

If its just a display issue, you can pipe it to the Format-List cmdlet:

get-childitem env:path | Format-List *
Skewer answered 14/8, 2019 at 11:13 Comment(0)
N
8

If it's just a display issue you can also use Select-Object

Get-ChildItem Env:\Path | Select-Object *

or get the property directly

(Get-ChildItem Env:\Path).Value

Running $env:PATH also works and will print the whole string value in case you don't need other properties, but if you want to print items in their own lines you can use

$env:Path -split ';'

or $env:Path -replace ';', "`n"

Some other alternatives being $env:PATH.Split(';') and $env:PATH.Replace(';', "`n")

Nippers answered 12/7, 2023 at 17:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.