gpt4 book ai didi

powershell - 将安装程序参数作为数组的索引传递

转载 作者:行者123 更新时间:2023-12-02 23:54:16 24 4
gpt4 key购买 nike

我正在尝试将参数传递给MSI安装程序:

$Servers = @("ServerOne", "ServerTwo", "ServerThree")

$InstallerArguments = @(
"/i `"$InstallerPath`"",
"/quiet",
"/log `"$LogFile`"",
"EMAILSERVER=`"$Servers[0]`"",
"DATABASESERVER=`"$Servers[1]`"",
"SHAREPOINTSERVER=`"$Servers[2]`"",
"USERNAME=`"$UserName`""
)

查看安装程序日志文件显示结果:
Property(S): EMAILSERVER = ServerOne ServerTwo ServerThree[0]
Property(S): DATABASESERVER = ServerOne ServerTwo ServerThree[0]

预期结果:
Property(S): EMAILSERVER = ServerOne

我想我需要以某种方式转义索引,代码有什么问题?

编辑(将参数传递给安装程序):
Start-Process -FilePath msiexec.exe -ArgumentList $InstallerArguments -Wait

最佳答案

这正是您想要的。我想你确实想要引号。

$Servers = @("ServerOne", "ServerTwo", "ServerThree")

$InstallerArguments = @(
"/i `"$InstallerPath`"",
"/quiet",
"/log `"$LogFile`"",
"EMAILSERVER=`"$($Servers[0])`"",
"DATABASESERVER=`"$($Servers[1])`"",
"SHAREPOINTSERVER=`"$($Servers[2])`"",
"USERNAME=`"$UserName`""
)

关于powershell - 将安装程序参数作为数组的索引传递,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49391330/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com