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

后端 未结 3 896
一整个雨季
一整个雨季 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: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.)

提交回复
热议问题