Environment variables in PowerShell with a dot (.) in the name

后端 未结 3 875
一整个雨季
一整个雨季 2021-01-01 08:52

I know I can access environment variables in PowerShell using $Env. For example, I can access FOO with $Env:FOO.

I can\'t figu

相关标签:
3条回答
  • 2021-01-01 09:40

    Use:

    Get-WMIObject Win32_Environment -filter "name='foo.bar'"
    
    0 讨论(0)
  • 2021-01-01 09:41

    Use the .NET method to get the variable:

    [Environment]::GetEnvironmentVariable("FOO.BAR")
    
    0 讨论(0)
  • 2021-01-01 09:42

    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.)

    0 讨论(0)
提交回复
热议问题