5

I can use this to get all of the user environment variables:

Get-ChildItem -Path Env:\

and this to get a single environment variable:

[System.Environment]::GetEnvironmentVariable('PATH','machine')

but what command can I use to view all machine level environment variables?

1 Answer 1

8

The System.Environment class has another static method GetEnvironmentVariables() (note the trailing "s"). You can call it without argument to get all environment variables (similar to Get-ChildItem env:), or with the same arguments as the second parameter of the GetEnvironmentVariable() method to get the variables for a particular target (e.g. machine, user, or process).

This will do what you want:

[Environment]::GetEnvironmentVariables('machine')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.