'Getting MSI Summary Information

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 $_
        }
  }


Solution 1:[1]

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

Solution 2:[2]

$Installer = New-Object -com WindowsInstaller.Installer
$Database = $Installer.GetType().InvokeMember("OpenDatabase", "InvokeMethod", $Null, $Installer, $($MsiFile,0))
$SummaryInfo = $Database.GetType().InvokeMember("SummaryInformation", "GetProperty",$Null , $Database, $Null)
$PropertyCount = $SummaryInfo.GetType().InvokeMember("PropertyCount", "GetProperty", $Null, $SummaryInfo, $Null)

(0..$PropertyCount) | ForEach { Write-Host $_ $SummaryInfo.GetType().InvokeMember("Property", "GetProperty", $Null, $SummaryInfo, $_) }


0 
1 1252
2 Installation Database
3 SlimDX Runtime .NET 4.0 x86 (January 2012)
4 SlimDX Group
5 Installer
6 This installer database contains the logic and data required to install SlimDX Runtime .NET 4.0 x86 (January 2012).
7 Intel;1033
8 
9 {98E616FB-251F-4FB4-A3AC-4773096EB5B5}
10 
11 
12 05.02.2012 1:22:04
13 05.02.2012 1:22:04
14 300

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Keith Hill
Solution 2 Cid