36

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...
3
  • 8
    $env:Path -replace ';', "`n" Commented Aug 14, 2019 at 11:25
  • 2
    $env:Path alone will expand the list so you can read it all. However, the replacement with CrLf is very nice. Commented Aug 9, 2023 at 18:36
  • 1
    Please consider selecting one of the answers as the solution to your question. Commented Feb 28, 2024 at 11:39

4 Answers 4

39

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

echo $env:path
Sign up to request clarification or add additional context in comments.

2 Comments

actually, there is no need for echo, you can just use :\>$env:path
Leave it to Microsoft developers and their supporters to convince us that $env:path is somehow to superior to just typing path. Why any developers want to type more characters to be productive is beyond my comprehension.
12

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

get-childitem env:path | Format-List *

Comments

10

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")

Comments

2

I know this question is asking for Powershell, but some people may also want to know what it is for a command window. In that case, it's simply path.

A search didn't find anything asking about this for a command prompt.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.