Output Windows Environment Variables from command line

The environment variables in Windows can be printed/Listed using the Windows command-line prompt (CMD) or using the PowerShell.

Windows Command-Line Prompt (CMD)

List all Windows environment variables and their values:

C:\> set
“Echo” the contents of a particular environment variable:

C:\> echo %ENVIRONMENT_VARIABLE%

Windows PowerShell

Print all Windows environment variables (names and values):

PS C:\> gci env:* | sort-object name
Show the contents of a particular environment variable:

PS C:\> echo $env:ENVIRONMENT_VARIABLE

Comments