Hi everyone,

does someone know how to read and change the SummaryInformation in a MSI package with PowerShell?

I am having already trouble with opening the information but please see below my code:

 

Thanks

Stephan

 Clear-Host
$installer = New-Object -ComObject WindowsInstaller.Installer
    $WorkingDir = "C:\Users\Desktop\"
    $MSI_file2 = "Sync.ism"

$scriptpath = Split-Path -parent $MyInvocation.MyCommand.Definition

$msiOpenDatabaseModeReadOnly = 0
$msiOpenDatabaseModeTransact = 1
$msiViewModifyUpdate = 2
$msiViewModifyReplace = 4
$msiViewModifyDelete = 6
$msiTransformErrorNone = 0
$msiTransformValidationNone = 0

function Invoke-Method ($Object, $MethodName, $ArgumentList) {
 return $Object.GetType().InvokeMember($MethodName, 'Public, Instance, InvokeMethod', $null, $Object, $ArgumentList)
}

function Get-Property ($Object, $PropertyName, [object[]]$ArgumentList) {
 return $Object.GetType().InvokeMember($PropertyName, 'Public, Instance, GetProperty', $null, $Object, $ArgumentList)
}

if ($database2 -ne $null){
[Runtime.InteropServices.Marshal]::FinalReleaseComObject($database2)
}
if ($summary -ne $null){
[Runtime.InteropServices.Marshal]::FinalReleaseComObject($summary)
}

$database2 = $Installer.GetType().InvokeMember("OpenDatabase", "InvokeMethod", $Null, $Installer, @(($WorkingDir + $MSI_file2), 0))

$summary = $database2.GetType().InvokeMember("SummaryInformation", "GetProperty", $Null, $database2, $Null, 1)

#$database2.GetType().GetProperty
$summary.GetType().InvokeMember("Persist", "InvokeMethod", $Null, $summary, $null)
write-host $test
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Answers

0

I've only a vbs script..
MSIDB = open ISM 

 

' Modify the Summary Information Stream

Set sumInfo = MSIDB.SummaryInformation(4)

sumInfo.Property(2) = ProductName' SIS Title

sumInfo.Property(3) = ProductName & " (v" & ProductVersion & ")"' SIS Subject

sumInfo.Property(4) = WFM_Company & " - " & PackagingTeam' SIS Author

sumInfo.Property(6) = GenericComment' SIS Comments

sumInfo.Persist

Set sumInfo = Nothing

 

 

' Commit the changes to the new database

MSIDB.Commit

 
Answered 03/26/2013 by: jaybee96
Red Belt

Please log in to comment
0

Hi,

yes, I found the same in the MSI vbs script collection but all my script is already powershell.

I use it to change values in the property and registry table and now would like also modify the schema verison of the MSI/ISM.

When I try it this way: $summary = $database2.GetType().InvokeMember("SummaryInformation", "GetProperty", $Null, $database2, 14)

I get this error:
InvokeMember : Exception calling "InvokeMember" with "5" argument(s): "SummaryInformation,UpdateCount"
 
At C:\Users\Desktop\schema.ps1:34 char:45
+ $summary = $database2.GetType().InvokeMember <<<< ("SummaryInformation", "GetProperty", $Null, $database2, 14)
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodTargetInvocation
Answered 03/26/2013 by: mac-duff
Second Degree Blue Belt

Please log in to comment
Answer this question or Comment on this question for clarity