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.
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.
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*'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With