Display all environment variables from a running PowerShell script Display all environment variables from a running PowerShell script powershell powershell

Display all environment variables from a running PowerShell script


Shorter version:

gci env:* | sort-object name

This will display both the name and value.


Shortest version (with variables sorted by name):

gci env:


I finally fumbled my way into a solution by iterating over each entry in the dictionary:

(gci env:*).GetEnumerator() | Sort-Object Name | Out-String