As the other posts point out, the most common shells do not allow for setting environment variables with periods in the name.
The “$_” is said to be the pipeline variable in PowerShell. The “$_” variable is an alias to PowerShell's automatic variable named “$PSItem“. It has multiple use cases such as filtering an item or referring to any specific object.
Environment variables in PowerShell are stored as PS drive (Env: ). To retrieve all the environment variables stored in the OS you can use the below command. You can also use dir env: command to retrieve all environment variables and values.
To access any kind of PowerShell variable where the name contains non-alphanumeric characters, use the ${…} notation as in:
${env:variable.with.dots} = "Hi there"
${env:variable.with.dots}
This works for variables in any drive (registry, filesystem, etc.)
Use the .NET method to get the variable:
[Environment]::GetEnvironmentVariable("FOO.BAR")
Use:
Get-WMIObject Win32_Environment -filter "name='foo.bar'"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With