PowerShell Tip: Installing MSI files

A great thing about PowerShell is that you can run any command line application from PowerShell. That is a common way to install software. Execute the installer from PowerShell is often the same as double clicking on it. If you start an MSI, it will pop up and start the install.


As you can see this works, but a better way is run it silently. Check the command line options with /? to see more useful parameters. As you can see there is also a /quiet option.

.\putty-64bit-0.69-installer.msi /quiet

You see the msiexec.exe into the task manager but it does not actually install anything. Eventually you go online and find out that you need to pass it to msiexec.exe as an argument with other flags.

msiexec.exe /I .\putty-64bit-0.69-installer.msi /quiet

This command actually ran into an error but the /quiet flag is suppressing it. The message would basically say that it could not find the specified MSI file. What we missing is the full path to the MSI installer.

msiexec.exe /I c:\users\lexh\Downloads\putty-64bit-0.69-installer.msi /quiet

The next issue that you to wait for the installer to finish. Executing msiexec directly starts the installer but returns control back to the PowerShell Script. The way to solve this,  is use of the PowerShell Start-Process -Wait parameter. This will wait until the process finishes before the script continue. The second thing is that Start-Process -Wait does ensure that your parameters are processed correctly.

Start-Process msiexec.exe -Wait -ArgumentList '/I c:\users\lexh\Downloads\putty-64bit-0.69-installer.msi /quiet'

Any time you are confused with command line arguments for an executable, use Start-Process -ArgumentList.

Below my example that I reuse in my PowerShell scripts for installing MSI files. Because I use this so often, that I wrap this in it’s own function.

$DataStamp = get-date -Format yyyyMMddTHHmmss
$logFile = '{0}-{1}.log' -f $file.fullname,$DataStamp
$MSIArguments = @(
    ('"{0}"' -f $file.fullname)
Start-Process "msiexec.exe" -ArgumentList $MSIArguments -Wait -NoNewWindow

This does not only a silent install, it also captures a verbose log file of the install.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s