How to print env vars in Windows PowerShell

To get all environment variables in Powershell, you can use the Powershell built-in $env:PATH

Example printing:

PS C:\Users\dev> $env:PATH

This would print like:

C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\dotnet\;C:\Python\Python39\Scripts\;C:\Python\Python39\;C:\Users\dev\AppData\Local\Microsoft\WindowsApps;C:\Users\dev\AppData\Local\Programs\Microsoft VS Code\bin;C:\Program Files\JetBrains\PyCharm Community Edition 2020.3.4\bin;C:\flutter\bin;C:\flutter\bin\cache\dart-sdk\bin

If you want to print each line separately, for better readability, use split along with it: (also refer to this page for more Split options – Powershell Split usage)

$env:path.split(";")

Example output:

PS C:\Users\dev> $env:path.split(";")
C:\Windows\system32
C:\Windows
C:\Windows\System32\Wbem
C:\Windows\System32\WindowsPowerShell\v1.0\
C:\Windows\System32\OpenSSH\
C:\WINDOWS\system32
C:\WINDOWS
C:\WINDOWS\System32\Wbem
C:\WINDOWS\System32\WindowsPowerShell\v1.0\
C:\WINDOWS\System32\OpenSSH\
C:\Program Files\dotnet\
C:\Python\Python39\Scripts\
C:\Python\Python39\
C:\Users\dev\AppData\Local\Microsoft\WindowsApps
C:\Users\dev\AppData\Local\Programs\Microsoft VS Code\bin
C:\Program Files\JetBrains\PyCharm Community Edition 2020.3.4\bin
C:\flutter\bin
C:\flutter\bin\cache\dart-sdk\bin

FAQs:

What are environment variables?

Environment variables, or Env Vars, are used to store small data, which the Windows system and other programs can access.