Query Environment Variables using PowerShell

by Sitaram Pamarthi on October 9, 2012

In this post I will show you how to query both user and computer environment variables using Powershell.

There are several ways available to query environment variables of a computer using Powershell. Out of them, I like dotnet way the most. The System.Environment  MSDN class has methods using which we can query user specific and computer specific environment variables of local computer. For easy understanding of usage, I am giving few examples below.

Query PATH environment variable of current logged on user:


Query PATH environment variable of computer:


Query TEMP environment variable of current logged on user:


Query TEMP environment variable of Computer:


After going through the above examples, you might have already got the idea about how to use [Environment]::GetEnvironmentVariable method. As you have noticed, this method takes two arguments. First one is name of the environment variable whose values you want to query and the second one is type of environment variable. This type has three possible values, User, Machine and Process. The User type represents user environment variable, Machine represents computer environment variable.


Hope this this helps…

This post was written by...

– who has written 503 posts on Techibee.com.

Sitaram Pamarthi is a windows administrators with 9+ years of experience.read more

{ 0 comments… add one now }

Leave a Comment

Previous post:

Next post: