Powershell MSI安装程序脚本

Powershell MSI安装程序脚本,powershell,windows-installer,Powershell,Windows Installer,请有人帮我写下面的powershell脚本好吗?我似乎无法启动安装程序:- $msiName = "D:\Folder\Build 1.9.0.39621 Setup.msi” Write-Host "Installing msi" $argumentlist = "/i [application] /qn /l*v log.txt LOGDIR=`"D:\Log`" SQLSERVER=`"xxx-xxx-xxxx-2`" DBAUTOBACKUP=`"0`" APPPOOLDOMAIN=`

请有人帮我写下面的powershell脚本好吗?我似乎无法启动安装程序:-

$msiName = "D:\Folder\Build 1.9.0.39621 Setup.msi”
Write-Host "Installing msi"

$argumentlist = "/i [application] /qn /l*v log.txt LOGDIR=`"D:\Log`" SQLSERVER=`"xxx-xxx-xxxx-2`" DBAUTOBACKUP=`"0`" APPPOOLDOMAIN=`"Test-as`" APPPOOLUSER=`"Testservice`" APPPOOLPASSWD=`"xxxxxxx`" ADQUERY=`"Test-as.net`" ADNAME=`"ultra`""

$application = $msiName
$argumentlist = $argumentlist.Replace("[application]",$application)

Start-Process -FilePath "C:\Windows\System32\msiexec.exe" -ArgumentList $argumentlist -Wait 
我试着简单地去做,但还是不行。以下是我尝试过的几种不同方法:-

(第一次尝试)

(第二次尝试)

(第三次尝试)

(第四次尝试)


我删除了旧答案

新的可能解决方案

ArgumenList
是一个字符串数组,因此它可以接受多个参数

Start-Process -FilePath "C:\Windows\system32\msiexec.exe" -ArgumentList "/i", "`"xxx yyyyy.msi`""
我尝试了一个安装程序,包括空白的名称,在我的机器上工作


希望对你有所帮助,这是我过去用过的,应该对你有用

    $argumentList = @(
        "-o",
        "$sourcefile",
        "-d",
        "$targetFolder"
    )
start-process -filepath $file -argumentlist $argumentList -wait -nonewwindow -passthru

你能把错误日志贴出来吗。我猜你在构建
参数列表时遇到了问题,有很多逃避。我建议通过格式运算符(,例如,`$argumentlist=(“/I{0}”-f$msiName))生成此字符串。感谢您的回复。我试着简化它,并按照你的建议去做(参见我编辑的原始信息),但它仍然不起作用。它甚至不会启动安装程序。我刚刚得到一个对话框弹出,说明启动msi的命令行格式,即“msiexec/Option[可选参数]……等等,如果你不再在文件名中加空格,你的生活会简单得多。我同意你的看法:这里似乎有一些转义问题。不过用反斜杠转义似乎没问题。也许可以试试
“$argumentlist“
?我不太确定。嗨,谢谢你的回复,但我还是不能让它工作。我甚至尝试过简化它。我试过以下方法:-嗨,安德烈亚斯。谢谢你的帮助。问题是,我想使用powershell命令“启动进程”,因为我想在我的powershell脚本中添加一个“-wait”,以便在msi安装完成之前,脚本不会继续执行下一行代码。@ED209,请检查答案更新,如果它对您是否合适。谢谢
$argumentList = ("/i {0}" -f "xxxxxx 1.9.0.39641 Setup.msi")

Start-Process -FilePath "C:\Windows\system32\msiexec.exe" -ArgumentList $argumentList 
$argumentList = ("/i {0}" -f "xxxxxx 1.9.0.39641 Setup.msi")

Start-Process -FilePath "C:\Windows\system32\msiexec.exe" -ArgumentList "$argumentList" 
Start-Process -FilePath "C:\Windows\system32\msiexec.exe" -ArgumentList "/i", "`"xxx yyyyy.msi`""
    $argumentList = @(
        "-o",
        "$sourcefile",
        "-d",
        "$targetFolder"
    )
start-process -filepath $file -argumentlist $argumentList -wait -nonewwindow -passthru