Set SummaryInformation in an msi using Powershell

I am atempting to edit msi files using powershell. I can edit almost every table but the "SummaryInformation" section is not really a table in the same way that the others are.

I can read properties from this information without any problem but I can't set anything.

From the information I have bbeen able to find online I should be able to set it using

$SummaryInfo.GetType().InvokeMember("Property", "SetProperty”, $null, $SummaryInfo,@(3,'test'))

But when I try this I get a very strange error,

Exception calling "InvokeMember" with "5" argument(s): "Property,Pid"

I only get this error when I specify the "@(3,'test')" array as @(int,string) or-else I get a type mismatch error. This leads me to believe I am close to the correct solution.

Any help would be appreciated.

Below is the code that I think should work.

$MSIPATH = "Path To MSI File"

$windowsInstaller = New-Object -ComObject WindowsInstaller.Installer 

$MSIDatabase = $windowsInstaller.GetType().InvokeMember("OpenDatabase", "InvokeMethod", $Null, $windowsInstaller, @($MSIPATH, 1)) 

$SummaryInfo = $MSIDatabase.GetType().InvokeMember(“SummaryInformation”, “GetProperty”,$Null , $MSIDatabase, $Null)

#get the porperty that I want to set
$SummaryInfo.GetType().InvokeMember(“Property”, “GetProperty”, $null, $SummaryInfo, @(3))

#Attempt to set the property this fails
$SummaryInfo.GetType().InvokeMember("Property", "SetProperty”, $null, $SummaryInfo,@(3,'test'))

Thanks to mklement0 I have found a solution

The code goes like this

$windowsInstaller = New-Object -ComObject WindowsInstaller.Installer 
$MSI = $windowsInstaller.OpenDatabase("Path to MSI", 1)

$SummaryInfo = $MSI.SummaryInformation(4)

$SummaryInfo.Property(3) = "Test"
$SummaryInfo.Persist()
$MSI.Commit()

Sometimes you just need someone to tell you that you are being dumb.

1 answer

  • answered 2018-11-08 08:08 BaronW

    Thanks to mklement0 I have found a solution

    I have not been able to do it in the same way I have been editing other tables. But have found a solution by using direct invocation.

    The code goes like this

    $windowsInstaller = New-Object -ComObject WindowsInstaller.Installer 
    $MSI = $windowsInstaller.OpenDatabase("Path to MSI", 1)
    
    $SummaryInfo = $MSI.SummaryInformation(4)
    
    $SummaryInfo.Property(3) = "Test"
    $SummaryInfo.Persist()
    $MSI.Commit()
    

    EDIT: to correct grammar