Reputation: 31
I am trying to access environment variables using Powershell. The environment variables, which is out of my control, contain periods in this format:
ENVIRONMENT_VARIABLE.1
Therefor, upon assigning the value of the environment variable to a local variable, it looks like this:
$myvar = $env:ENVIRONMENT_VARIABLE.1
However, every time I try to retrieve this variable, it always leaves out the ".1", returning nothing.
I'm aware periods + Bash = no bueno, but again, this is out of my control and I need a work around. If it helps, I already tried this as well with no luck:
$myvar = ${env:ENVIRONMENT_VARIABLE.1}
I appreciate any and all help on this. Thanks!
Upvotes: 0
Views: 1691
Reputation: 201992
The last format you're using works for me:
PS> ls env:\fo*
Name Value
---- -----
Foo.1 bar.1
PS> ${env:foo.1}
bar.1
Upvotes: 3