Tuesday, 3 April 2012

Install multiple MSI using Powershell

If you want to install more than one msi using powershell you can't just invoke the files. If you do so not all of them will get installed because Powershell won't wait one to finish to start the other.

In a batch file you would use Start msiexec file.msi /wait

In Powershell is similar and it's very good specially for Task Sequences.

First let's create an array with the msi files.

$msi = @("c:\file1.msi", "c:\file2.msi", "c:\file2.msi")

Now we call the Start-Process and wait one to finish before starting the next.

foreach($_ in $msi)
{Start-Process -FilePath msiexec -ArgumentList /i, $_, /qn -Wait}


You can also output the result to null and it will wait for its finish:

foreach($_ in $msi)
{msiexec /i $_ /qn | out-null}

No comments:

Post a Comment