How can I get property names from a ComObject in Powershell?

80 views Asked by At

This code pulls summary information from an MSI or MSP file. I'm trying to figure out how to enumerate the property names, rather than just the property values, the below only outputs the value. How can I get the associated property name as well?

$directory = "xxxx";
$msiPath = Get-ChildItem -Path $workDir -Include "*.msi" , "*.msp" -Recurse | % {$_.FullName} ;
$installer = New-Object -com WindowsInstaller.Installer;
$database = $installer.GetType().InvokeMember("OpenDatabase", "InvokeMethod", $null, $installer, $($msiPath,0));
$summaryInfo = $database.GetType().InvokeMember("SummaryInformation", "GetProperty",$null , $database, $null);
$propertyCount = $summaryInfo.GetType().InvokeMember("PropertyCount", "GetProperty", $null, $summaryInfo, $null);
for ($i = 0; $i -le $propertyCount; $i++)
{
    Write-Host $i $summaryInfo.GetType().InvokeMember("Property", "GetProperty", $null, $summaryInfo, $i);  
    
}
0

There are 0 answers