How to assign and reference environment variables containing square brackets in Powershell
问题 When the PSDrive is not specified, the following works: ${[foo]}="bar" echo ${[foo]} But the following does not work $env:${[foo]}="bar" At line:1 char:1 + $env:${[foo]}="bar" + ~~~~~ Variable reference is not valid. ':' was not followed by a valid variable name character. Consider using ${} to delimit the name. At line:1 char:6 + $env:${[foo]}="bar" + ~~~~~~~~~~~~~~ Unexpected token '${[foo]}="bar"' in expression or statement. + CategoryInfo : ParserError: (:) [],