-
Notifications
You must be signed in to change notification settings - Fork 22
Installing, repairing, and uninstalling products and patches
- Basic install
- Add features to an installed product
- Forcibly reinstalling all components
- Uninstall all products matching a pattern
- Installing all advertised features on a machine
All install, repair, and uninstall cmdlets log verbosely to the $env:TEMP
directory by default using the pattern MSI-*.log. These logs are timestamps and may be additional sortable with a step identifier (e.g. installing a patch applicable to multiple products will have the same base log name but incremental step identifiers). This is the same as my specification for logging as used in the Burn chainer for WiX.
All cmdlets will also prompt for UAC consent, if required, unless you pass the -Force
parameter. This is consistent with msiexec.exe. If you want to use these cmdlets in unattended automation scripts, I recommend you pass -Force
or the scripts may block waiting for user input until the UAC consent dialog times out and fails the install.
Note: If product and patch packages are installed with a chainer like Visual Studio that you install, repair, and uninstall the product using that chainer. There may be additional logic and properties applied during those operations you don't know about.
By default, all packages are installed with separate progress bars. This best mimics the behavior of Windows installer.
install-msiproduct product.msi
For product packages that support it, you can also redirect the target directory (TARGETDIR
) using the -Destination
parameter (alias: -TargetDirectory
).
install-msiproduct product.msi -target C:\Product
You can also pass any number of properties like you would to msiexec.exe to, for example, add features to an installed product. Notice how you don't need to specify a parameter name if all required parameters are assigned.
install-msiproduct "{851278A4-852F-410A-9FF7-B345C41DBE35}" ADDLOCAL=OptionalFeature
If you pipe the product installation to install-msiproduct
, just pass additional properties after the -Properties
parameter.
get-msiproductinfo "{851278A4-852F-410A-9FF7-B345C41DBE35}" | install-msiproduct -properties ADDLOCAL=OptionalFeature
The default REINSTALLMODE
is "omus", but you can use a different mode - either by tab-completed enumerations or the single characters used by Windows Installer.
repair-msiproduct "{851278A4-852F-410A-9FF7-B345C41DBE35}" -reinstall FileReplace, MachineData, UserData, Shortcut
This is equivalent to the REINSTALLMODE
of "amus", which you can also use in the following pipeline example.
get-msiproductinfo "{851278A4-852F-410A-9FF7-B345C41DBE35}" | repair-msiproduct -reinstall "amus"
If you have a group of related products you want to uninstall and show a single, unified progress bar using the -Chain
parameter (which all the cmdlets mentioned here support), you can use the following command.
get-msiproductinfo -name "**My Product**" | uninstall-msiproduct -chain -force
This will also remove any patches applied to those products.
In an old - but still relevant - blog post I described the conditions, problems, and resolution of how features can be incidentally advertised. Here is an example using these cmdlets to fix the problem instead of Windows Script referenced in the solution.
Note: Some products actually use advertisement as a supported feature (e.g. Microsoft Office) but running a command like the following would fix both incidentally advertised features and merely install advertised features even if intended.
get-msiproductinfo | get-msifeatureinfo | where { $_.State -eq "Advertised" } | group ProductCode | select @{l="ProductCode"; e={$_.Name`, @{l="CommandLine"; e={"ADDLOCAL=$(($_.Group | select -expand Name) -join ',')"` | foreach { $_ | install-msiproduct -properties $_.CommandLine }
Copyright (C) Microsoft Corporation. All rights reserved. Licensed under the MIT license. See LICENSE.txt in the project root for license information.
Commands
- Add-MSISource
- Clear-MSISource
- Edit-MSIPackage
- Export-MSIPatchXml
- Get-MSIComponentInfo
- Get-MSIComponentState
- Get-MSIFeatureInfo
- Get-MSIFileHash
- Get-MSIFileType
- Get-MSILoggingPolicy
- Get-MSIPatchInfo
- Get-MSIPatchSequence
- Get-MSIProductInfo
- Get-MSIProperty
- Get-MSIRelatedProductInfo
- Get-MSISharedComponentInfo
- Get-MSISource
- Get-MSISummaryInfo
- Get-MSITable
- Install-MSIAdvertisedFeature
- Install-MSIPatch
- Install-MSIProduct
- Measure-MSIProduct
- Remove-MSILoggingPolicy
- Remove-MSISource
- Repair-MSIProduct
- Set-MSILoggingPolicy
- Test-MSIProduct
- Uninstall-MSIPatch
- Uninstall-MSIProduct
Examples