我被要求使用Powershell自动化大型MSI安装程序。这个安装程序有很多安装选项,我在下面的语法中逐个运行选项。
我有这个设置来运行所有安装选项,然后检查日志中是否有日志中的任何故障并向我发送电子邮件通知。我无法解决的问题是,如果安装选项失败,则在poweshell中运行的安装程序会向UI抛出一个错误框并暂停安装。这是一个问题,因为我需要运行所有安装,然后评估失败并及时修复。这是正常行为还是我可以修改下面的代码,以便在UI中不显示错误消息?
#Common items
$SourceDirectory = "D:\Temp"
$LogDirectory = "D:\Temp\Script"
$FileName = Get-ChildItem -Path $SourceDirectory | Sort-Object LastAccessTime - Descending | Select-Object -First 1
$FullFileName = $SourceDirectory + "\" + $FileName
#Install option 1
$LogName = $LogDirectory + "\" +"(MSIName).log"
$Arguments = "/i ""$FullFileName"" /qn /norestart /L*V $LogName ADDLOCAL=(install options)"
Start-Process -FilePath msiexec.exe -ArgumentList $Arguments -Wait
#Install option 2
$LogName = $LogDirectory + "\" +"(MSIName).log"
$Arguments = "/i ""$FullFileName"" /qn /norestart /L*V $LogName ADDLOCAL=(install options)"
Start-Process -FilePath msiexec.exe -ArgumentList $Arguments -Wait
我在这里缺少什么?我正在以/ qn身份运行。
答案 0 :(得分:2)
即使在安静模式下,编辑不当的安装程序也可能显示UI。检查详细日志以查看消息的来源。