I have the name of an environment variable in a variable and I want to get the value. How do I do that? I\'ve tried:
PS C:\\Users\\Joe> $v=\"USERDOMAIN\"
Two lines
$v = "Path" (get-item env:$v).Value
One line
iex ('$env:' + $x)
To complement Vladimir's helpful answer with a solution that makes direct use of the .NET framework:
$v="USERDOMAIN" [Environment]::GetEnvironmentVariable($v)