【发布时间】:2022-01-10 05:39:20
【问题描述】:
有没有办法将两个字符串组合成一个当前变量并从中获取数据?我不确定是否有其他方法可以做到这一点。如果有的话,请告诉我。谢谢!
这是我的代码。
$App1 = "Google Chrome"
$App2 = "Mozilla"
$AppExt1 = ".exe"
$AppExt2 = ".msi"
$Apps = @('1','2')
ForEach ($Applications in $Apps) {
$AppToBeInstalled = '$App' + $_
$AppExt = '$AppExt' + $_
Write-Host "Application $AppToBeInstalled to be installed with extension $AppExt"
}
我想要什么。
Application Google Chrome to be installed with extension .exe
Application Mozilla to be installed with extension .msi
但我只得到空结果。
Application to be installed with extension
Application to be installed with extension
【问题讨论】:
标签: powershell script