Getting MSI Summary Information

powershell, summary, windows-installer

Solution

Go pick up a copy of WiX. It comes with a .NET wrapper for MSI that makes this easier e.g.:

PS> Add-Type -Path 'C:\Program Files (x86)\WiX Toolset v3.6\bin\Microsoft.Deployment.WindowsInstaller.dll'
PS> $db = new-object Microsoft.Deployment.WindowsInstaller.Database "$pwd\TypeScriptSetup.0.8.1.msi"
PS> $db.SummaryInfo


Title          : Installation Database
Subject        : TypeScript for Microsoft® Visual Studio® 2012
Author         : Microsoft Corporation
Keywords       : Installer
Comments       : This installer database contains the logic and data required to install TypeScript for Microsoft®
                 Visual Studio® 2012.
Template       : Intel;1033
LastSavedBy    :
RevisionNumber : {B41DBDE5-CF50-42FB-AF8A-13EA3003BCA1}
CreatingApp    : Windows Installer XML (3.6.3303.0)
LastPrintTime  : 1/1/0001 12:00:00 AM
CreateTime     : 11/14/2012 3:38:30 PM
LastSaveTime   : 11/14/2012 3:38:30 PM
CodePage       : 1252
PageCount      : 500
WordCount      : 2
CharacterCount : 0
Security       : 2
Handle         : 8
IsClosed       : False

Problem

i want to get the MSI Summary Information with PowerShell i found several scripts and code snippets for opening the "normal" Tables of MSI. So here is my question, how can open the Summary Information with PowerShell? I attach some code snippets you might find useful. My Code for getting the Summary Information which doesn't work! ``` function Get-SummaryInformation ( [IO.FileInfo] $FilePath ){ try { $windowsInstaller = New-Object -com WindowsInstaller.Installer $database = $windowsInstaller.GetType().InvokeMember(“OpenDatabase”, “InvokeMethod”, $Null, $windowsInstaller, @($FilePath.FullName, 0)) $summary = $database.GetType().InvokeMember(“SummaryInformation”, “Invoke-Method”, $Null, $database, ([2])) $MSI_Summary[1]=$summary.text } catch { throw "ERROR - " + $_ } } ``` Code for gettin Normal MSI Tables ``` function Get-MsiProductCode ( [IO.FileInfo] $FilePath ) { try { $windowsInstaller = New-Object -com WindowsInstaller.Installer $database = $windowsInstaller.GetType().InvokeMember(“OpenDatabase”, “InvokeMethod”, $Null, $windowsInstaller, @($FilePath.FullName, 0)) $q = "SELECT `Value` FROM `Property` WHERE `Property` = 'ProductCode'" $View = $database.GetType().InvokeMember(“OpenView”, “InvokeMethod”, $Null, $database, ($q)) $View.GetType().InvokeMember(“Execute”, “InvokeMethod”, $Null, $View, $Null) $record = $View.GetType().InvokeMember(“Fetch”, “InvokeMethod”, $Null, $View, $Null) $global:ProductCode = $record.GetType().InvokeMember(“StringData”, “GetProperty”, $Null, $record, 1) } catch { throw "Failed to get MSI file version the error was: {0}." -f $_ } } ```

Original source