Powershell allows you to access the Windows Environment Variables. This is very useful in collecting system information . I’ve applied this technique in creating an inventory report or troubleshooting a server issue. The purpose of Environment variables is to set values at the OS level – that will impact processes. Accessing and reporting on the variables quickly can assist in maintaining server uptime.

A straightforward way of accessing all the environment variables is to use “Dir env:\” . A full list of environment variables will appear. Although the full list appears , it requires some string manipulation to isolate one variable and value. Powershell allows you to access the individual Environment variables .

When scripting , there is a requirement to access the environment variables individually. To access individually use $env followed by the Windows Environment variable . The example includes the common Environment Variables, although use “Dir env:\” to view the full list of variables