Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can I display environment variables in PowerShell, and be able to distinguish between which ones are "user" vars and which ones are "system" vars?

share|improve this question

3 Answers 3

Not a powershell pro, but at worst, you could go fish around in the registry to see whether the vars you're interested in are showing up there. Inside a given session, I'm not really sure there's any distinction between user/sys vars other than the registry storage location...

Pertinent keys are:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
HKEY_CURRENT_USER\Environment
share|improve this answer
1  
Correct: in process there is no distinction. And of course PATH is a combination of system and user settings so as set is neither. –  Richard Apr 6 '11 at 8:06

To find out within PowerShell:

Get-ItemProperty -Path 'Registry::HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment'

Get-ItemProperty -Path 'Registry::HKCU\Environment'
share|improve this answer

Since PowerShell has access to the .NET Framework, you could use

[System.Environment]::GetEnvironmentVariables([System.EnvironmentVariableTarget]::Machine) [System.Environment]::GetEnvironmentVariables([System.EnvironmentVariableTarget]::Process) [System.Environment]::GetEnvironmentVariables([System.EnvironmentVariableTarget]::User)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.