Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows 在Powershell中使用批处理样式的环境变量解释字符串_Windows_Powershell_Batch File_Environment Variables_Appv - Fatal编程技术网

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