2

I wanted to create an Environment Variable that's stored system-wide.

What I've used in Powershell:

$Env:MyVar = 'Some value'

With gci Env: I can confirm, that the variable has been created successfully. However it was still missing in the Advanced System Settings in Windows (Win11).

How do I set it up to be visible in that menu?

0

1 Answer 1

4

I found the solution by the time of writing the question. Though simple I still wanted to share this information.

To create a system-wide Environment Variable I used the following code:

[Environment]::SetEnvironmentVariable('MyVariable', 'Some value', 'Machine')

Make sure to start Powershell with elevated privileges (admin) for creating a system-wide variable.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.