Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display all environment variables from a running PowerShell script

People also ask

How do I see all environment variables in PowerShell?

How do I do this in PowerShell? Answer: You can do this in one line using the env: PowerShell drive to display all of the currently set Environment variables.

How do I get a list of all environment variables?

To list all the environment variables, use the command " env " (or " printenv "). You could also use " set " to list all the variables, including all local variables.

What is $ENV in PowerShell?

The $env:PSModulePath environment variable contains a list of folder locations that are searched to find modules and resources. By default, the effective locations assigned to $env:PSModulePath are: System-wide locations: These folders contain modules that ship with PowerShell.


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

Short version with a wild card filter:

gci env: | where name -like 'Pro*'