Examples
Below are some examples of what you can do with Windows Installer PowerShell Extensions, organized by cmdlets. For pre-defined formats to use below, see
Formats.
Get-MSIFileHash
Get-MSIFileHash gets the 128-bit hash of files in a format compatible for storing in the
MsiFileHash table. The where-object clause is there because these MSIHashPart* properties are not added to directories, and format-table determines columns based on the first item passed to it which is typically a directory.
dir $env:temp | ? { $_.PSIsContainer -eq $False } | get-msifilehash -passthru | ft name, msi* -auto
Get the file hashes for all files in the TEMP directory.
Get-MSIPatchInfo
Get-MSIPatchInfo gets information for applied, superseded, and obsolesced patches. Patches are only published on the system if they apply to a product already installed or advertised.
get-msipatchinfo -filter all | get-itemproperty | format-table fullname, lastwritetime, length -autosize
Get patch sizes for all installed patches
get-msipatchinfo -filter superseded | format-table patchcode, patchstate -group productcode -autosize
Identify superseded patches for installed products
get-msipatchinfo | where { $_.DisplayName -like "*KB123456*" } | group ProductCode | foreach {
start msiexec.exe "/uninstall `"$( ($_.Group | select -expand PatchCode) -join ';')`" /package `"$($_.Name)`"" -wait
}
Uninstall all patches with the same identity from all products efficiently.
Get-MSIProductInfo
Get-MSIProductInfo gets information for installed and advertised products.
get-msiproductinfo | ? {$_.productname -match "Visual Studio"} | format-table productcode, productname, versionstring -autosize
Get which Visual Studio products are installed
$ntaccount = new-object System.Security.Principal.NTAccount "domain\user"
$sid = $ntaccount.Translate([System.Security.Principal.SecurityIdentifier])
get-msiproductinfo -install userunmanaged -user $sid
Get which products are installed for another user (requires elevation)
Get-MSISource
Get-MSISource gets the source list for installed products.
get-msiproductinfo | % { ($_.ProductName); $_ | get-msisource | sort Index | ft SourceType, Path -auto }
Show the source list for each installed product