Windows 在Powershell中使用批处理样式的环境变量解释字符串
我有一个字符串,其中包含以批处理方式表示的环境变量(Windows 在Powershell中使用批处理样式的环境变量解释字符串,windows,powershell,batch-file,environment-variables,appv,Windows,Powershell,Batch File,Environment Variables,Appv,我有一个字符串,其中包含以批处理方式表示的环境变量(%programdata%\App-V),需要在Powershell中进行计算。能否在Powershell中轻松计算%ENV%符号? 我知道Powershell中环境变量的常用符号是$env:ProgramData,但字符串是从另一个命令返回给我的,我无法更改 背景资料: Powershell Cmdlet((Get-AppvClient配置-Name PackageInstallationRoot).Value)奇怪地返回一个带有批处理样式环
%programdata%\App-V
),需要在Powershell中进行计算。能否在Powershell中轻松计算%ENV%
符号?
我知道Powershell中环境变量的常用符号是$env:ProgramData
,但字符串是从另一个命令返回给我的,我无法更改
背景资料:
Powershell Cmdlet(
(Get-AppvClient配置-Name PackageInstallationRoot).Value
)奇怪地返回一个带有批处理样式环境变量的字符串(%programdata%\App-V
)。您可以使用[environment]
类型加速器:
[environment]::ExpandEnvironmentVariables('%programdata%\App-V')
返回C:\ProgramData\App-V