If you want to install more than one MSI package, you can not use Invoke-item, otherwise PowerShell will not wait for the previous installation package to complete, it has already run the next installation package.
If you are in a batch, we may use Msiexec file.msi/wait. Msiexec can also be used in PowerShell.
Store the installation package paths in the array first:
The code is as follows:
$msi = @ ("C:\file1.msi", "C:\file2.msi", "C:\file2.msi")
Then use the-wait parameter of the start-process to wait until the previous installer has finished running and then start the next one:
The code is as follows:
foreach ($_ in $msi)
{
Start-process-filepath msiexec-argumentlist/i, $_,/qn-wait
}
Another option is to redirect the output to some null, and also to ensure that the program waits for the installation to complete:
The code is as follows:
foreach ($_ in $msi)
{
msiexec/i $_/qn | Out-null
}
Article Source: http://www.pstips.net/install-multiple-msi-using-powershell.html
This article comes from the "Ricky's blog" blog, please be sure to keep this source http://57388.blog.51cto.com/47388/1643886
PowerShell--How to install MSI suffix software in bulk