HOWTO · PowerShell
How to Install MSI File in PowerShell
Install a Windows MSI package from PowerShell with msiexec.exe, wait for completion, interpret its exit code, and troubleshoot common launch problems.
On this page
To install a Windows Installer package from PowerShell, start msiexec.exe with the package path and installation options. Use Start-Process with -Wait and -PassThru when a script must wait for completion and inspect the installer process’s exit code.
Understand the MSI installation task
An MSI file is a Windows Installer package. PowerShell can launch its installation, but the package and Windows Installer service perform the installation itself. The commands below are for Windows. Use a path to an MSI accessible to the account running the command; an elevated PowerShell session may be required to install software for all users or write protected locations.
Install an MSI with Start-Process
Pass msiexec.exe as the program and the package path as an argument to its /i option. Quote the package path so spaces remain part of one argument. Replace the sample path with the real location of your package. The self-contained example previews the argument string; it does not launch an installer. On Windows, run the resulting arguments with Start-Process -FilePath 'msiexec.exe' -ArgumentList $arguments -Wait -PassThru, then inspect the returned process as described below.
Run this self-contained argument preview:
$msiPath = 'C:\Packages\Example.msi'
$arguments = "/i `"$msiPath`" /qn /norestart"
"msiexec.exe $arguments"
msiexec.exe /i "C:\Packages\Example.msi" /qn /norestart
/i requests installation, /qn requests no user interface, and /norestart prevents Windows Installer from restarting the computer automatically. Quiet mode gives no interactive progress, so use it only when that behavior suits your deployment. The package can still require properties, licensing values, or other options; consult its documentation. The preview is portable, while the actual installation command is Windows-specific.
Pass options and wait for completion
-Wait keeps the PowerShell script from continuing until the process ends. -PassThru returns a process object, whose ExitCode is available after it exits. Without waiting, a script may move on before installation finishes. /norestart controls installer restart behavior; it does not guarantee that every package will avoid requesting a later restart. Plan for restart requirements in the deployment process.
Check the installation result
Do not print a success message merely because Start-Process returned. Check the process exit code: Windows Installer uses 0 for success, 3010 when installation succeeded but a restart is required, and other codes to indicate different outcomes. Handle the codes relevant to your deployment and record them in your own logging system. If the process cannot start, PowerShell reports a launch error; if it starts and fails, investigate the installer exit code and package log.
For a diagnostic log, add a log path to the argument string, such as /L*V "C:\Logs\Example-install.log", and make sure the directory exists and is writable. Review the log around the reported failure. Do not treat a started process or a quiet window as proof that the product installed correctly.
Choose an installation method
Start-Process is the direct choice here because it launches the Windows Installer executable with explicit arguments and can wait for its result. Invoke-Expression executes a constructed PowerShell command string; avoid using it to assemble this invocation because quoting paths and arguments is harder to reason about. Pass data as process arguments instead of turning it into executable command text.
Win32_Product is a WMI class for installed Windows products, not the recommended route for installing an MSI. Querying it can trigger Windows Installer consistency checks, so it is unsuitable as a general inventory or installation shortcut. Use the package’s documented deployment method or msiexec.exe for this task.
Install on a remote computer
A local Start-Process command runs on the local computer. To run an installation remotely, use an approved deployment tool or a configured PowerShell remoting session, with permission to access the target and the MSI from that computer. The package path must resolve on the remote machine or through a location its installer process can read; a drive mapped only in your local interactive session may not be available remotely. Remote execution does not bypass Windows permissions or deployment policy.
Prerequisites and troubleshooting
Confirm that the MSI path exists and is readable by the account running the process, and that the target machine supports the package. For access-denied errors, check elevation and deployment permissions. For a process-start error, verify that Windows and msiexec.exe are available. For a nonzero installer code, check the package log, required properties, pending restart state, and whether another installation is in progress. Keep the exit code with deployment logs so you can distinguish a successful install that needs a restart from a failed install.