Summary: Doctor Scripto demonstrates how to use env: to show all currently set environment variables
Question: Hey Doctor Scripto, I remember in DOS if I wanted to see the values of all the Environment variables; like TEMP I could just type the SET Command. 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.
dir env:
PowerShell, Doctor Scripto, PowerTip, Sean Kearney
A few shorter ways (all the same, just different aliases)
dir env:
gci env:
ls env:
All are aliased to
Get-ChildItem env:
Also, you can do this:
cd env:
Which keeps your current location in the Environment provider. Just use
CD c:
(or its alias, sl c: )
to get back.
Another fun party trick? Try this:
$env:path – split ‘;’
When PowerShell is locked down in safe mode, you are not allowed to call methods on object for security reasons, so using System.Environment is out of the question then. The right way to get to environment variables in PowerShell is the Env: PSDrive. The requested “set” equivalent would just be “dir env:”. This should always work, even if calling methods on object is disallowed, I think.
Handy. I also like: ls env:\