Typically, in PowerShell you would use

env:VARIABLE = "Some kind of value"

But my issue is that I have the name of the variable in a string object. PowerShell does not recognize it as a string object and uses the variable name as the name of the environment variable.

For example, if I do this:

$someVariable = "MY_ENV_VAR"
env:$someVariable = "Some kind of value"

The result is $someVariable being literally defined as an environment variable instead of MY_ENV_VAR. I've tried numerous iterations of using ${} as if there were periods in the string, but nothing I have found works.

How can I use PowerShell's Env: using a string object?

Edit
Report