How to Print List Existing Environment Variable using Power Shell in Microsoft Windows

Posted on

How to Print List Existing Environment Variable using Power Shell in Microsoft Windows

For listing existing environment variable, it can be done in the Power Shell. Basically, there are several available environment variable exist in the device which is running using Microsoft Windows as its operating system. In other words, it is possible to list all of them without having to define all of those right before listing it. All of those environment variables normally have already exist or have been defined before. Those environment variables can be printed  in the form of list. So, there is a certain command available for listing all of those environment variables which already been defined and it already exist before.

Table of Contents

Introduction

As for the short explanation about this article, it just explain how to print list of environment variables. There is a specific command used to print all of the existing environment variables in the form of list.

How to Print List Existing Environment Variable using Power Shell in Microsoft Windows

In order to print the list of all existing environment variable, below are the steps in order to do it using Power Shell in Microsoft Windows :

  1. Running Power Shell will be the first step to do it. A specific way to run it is just searching it through. Start pressing the Start button for displaying the textfield search. Type  ‘power shell’ keyword, then it will display the search result.

  2. Following the appearance of the search result, click the link pointing to the Power Shell application. Shortly after, it will present the Power Shell application which exist in the device. The following appearance of the  Power Shell with be presented as follows  :

    How to Print Temporary Environment Variable using Power Shell in Microsoft Windows
    How to Print Temporary Environment Variable using Power Shell in Microsoft Windows

Having successfully run the Power Shell in the previous section, just continue the process. Just do following step in order to print the list of the environment variables :

  1. Make sure that the Power Shell is active and it is showing the following appearance :

    Windows PowerShell
    Copyright (C) Microsoft Corporation. All rights reserved.
    
    Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows
    
    PS C:\Users\Personal>
    
  2. Type the following command in order to print list of existing environment variables  :

    Windows PowerShell
    Copyright (C) Microsoft Corporation. All rights reserved.
    
    Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows
    
    PS C:\Users\Personal> ls env:
    
    Name Value
    ---- -----
    ALLUSERSPROFILE C:\ProgramData
    APPDATA C:\Users\Personal\AppData\Roaming
    CommonProgramFiles C:\Program Files (x86)\Common Files
    CommonProgramFiles(x86) C:\Program Files (x86)\Common Files
    CommonProgramW6432 C:\Program Files\Common Files
    ...
    ComSpec C:\WINDOWS\system32\cmd.exe
    DriverData C:\Windows\System32\Drivers\DriverData
    EFC_38172 1
    FPS_BROWSER_APP_PROFILE_STRING Internet Explorer
    FPS_BROWSER_USER_PROFILE_ST... Default
    ...
    HOMEDRIVE C:
    HOMEPATH \Users\Personal
    INTEL_DEV_REDIST C:\Program Files (x86)\Common Files\Intel\Shared Libraries\
    JAVA_HOME C:\Program Files\Java\jdk-17.0.2
    LOCALAPPDATA C:\Users\Personal\AppData\Local
    ...
    MIC_LD_LIBRARY_PATH C:\Program Files (x86)\Common Files\Intel\Shared Libraries\compiler\lib\mic
    NUMBER_OF_PROCESSORS 8
    OneDrive C:\Users\Personal\OneDrive
    OS Windows_NT
    Path C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64\compiler;C:\Users\Personal ...
    PATHEXT .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.CPL
    POSTGIS_ENABLE_OUTDB_RASTERS 1
    POSTGIS_GDAL_ENABLED_DRIVERS GTiff PNG JPEG GIF XYZ DTED USGSDEM AAIGrid
    PROCESSOR_ARCHITECTURE x86
    PROCESSOR_ARCHITEW6432 AMD64
    PROCESSOR_IDENTIFIER Intel64 Family 6 Model 140 Stepping 1, GenuineIntel
    PROCESSOR_LEVEL 6
    PROCESSOR_REVISION 8c01
    ProgramData C:\ProgramData
    ProgramFiles C:\Program Files (x86)
    ProgramFiles(x86) C:\Program Files (x86)
    ProgramW6432 C:\Program Files
    ...
    PSModulePath C:\Program Files\WindowsPowerShell\Modules;C:\Users\Personal\Documents\WindowsPowerShell\Modules;C...
    PUBLIC C:\Users\Public
    SESSIONNAME Console
    SystemDrive C:
    SystemRoot C:\WINDOWS
    TEMP C:\Users\Personal\AppData\Local\Temp
    TMP C:\Users\Personal\AppData\Local\Temp
    USERDOMAIN LAPTOP-6EV9VAU3
    USERDOMAIN_ROAMINGPROFILE LAPTOP-6EV9VAU3
    USERNAME Personal
    USERPROFILE C:\Users\Personal
    ...
    ...
    ...
    
    PS C:\Users\Personal>

As in the output above, the command executed in the Power Shell is already showing list of existing environment variables without having to define it first. As a further reference, just check the embedded video below :

Leave a Reply