PowerTip: Use Windows PowerShell to display all Environment variables

Doctor Scripto

Summary: Doctor Scripto demonstrates how to use env: to show all currently set environment variables

A picture containing scissors Description automatically generated

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



Discussion is closed. Login to edit/delete existing comments.

  • Ray Megal 0

    Handy. I also like: ls env:\

  • Jarno Peschier 0

    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.

  • Alan McBeeMicrosoft employee 0

    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 ‘;’

Feedback usabilla icon