Summary
You may want to read info from an existing .msi at times. This can be done with PowerShell.
Description
The PowerShell may use a COM Windows installer object. Open the .msi as a database, use a view to execute a query and fetch the data.
Below is an example of PowerShell querying the shortcut table of an .msi for values.
Other tables can be queried by changing the select statement in line:
$ShortcutsView = $MSI.OpenView("select * from Shortcut")
Column values can be retrieved from other columns by changing number value in the line:
Write-Output (Get-Property $Shortcuts StringData 1)
Example
The following is an example of using PowerShell to retrieve info from an .msi:
$windowsInstaller = New-Object -ComObject WindowsInstaller.Installer
function Get-Property ($Object, $PropertyName, [object[]]$ArgumentList) {
return $Object.GetType().InvokeMember($PropertyName, 'Public, Instance, GetProperty', $null, $Object, $ArgumentList)
}
$MSI = $windowsInstaller.OpenDatabase("C:\InstallShield 2019 Projects\My Project Name-1\Product Configuration 1\Release 1\DiskImages\DISK1\My Project Name-1.msi", 0)
$ShortcutsView = $MSI.OpenView("select * from Shortcut")
$ShortcutsView.Execute()
$Shortcuts = $ShortcutsView.Fetch()
write-host "First 5 fields of Shortcut table" -ForegroundColor Green
if ($Shortcuts) {
Write-Output (Get-Property $Shortcuts StringData 1)
Write-Output (Get-Property $Shortcuts StringData 2)
Write-Output (Get-Property $Shortcuts StringData 3)
Write-Output (Get-Property $Shortcuts StringData 4)
Write-Output (Get-Property $Shortcuts StringData 5)
}
$ShortcutsView.Close()
$MSI.Commit()
$MSI = $null
[system.gc]::Collect()
[System.gc]::waitforpendingfinalizers()
Additional Information
Here is a link to documentation on the COM Windows installer object:
https://docs.microsoft.com/en-us/windows/win32/msi/installer-object
Related Articles
How to Use PowerShell to Create a Self-Signed Digital Certificate to Test Digital Signing with InstallShield 41Number of Views Using PowerShell to Retrieve Active Directory Account Properties 14Number of Views Intune adapter fails to retrieve data when configured to use a web proxy 5Number of Views Several PowerShell-based inventory adapters fail to use configured web proxy details 6Number of Views Use PowerShell to Create a Project and Add a PowerShell Custom Action Using the InstallShield Automation Interface 14Number of Views
Hi, I am Reva - Ask me anything.
No new updates
Thanks for the feedback!
Your feedback has been saved.Rate this response:
Add Additional feedback ( Optional )
Are you sure you want to cancel
the case creation?
Are you sure you want to cancel the case creation?
Are you sure you want to close this case
| Products | Region | Phone Numbers |
|---|---|---|
| FlexNet Operations FlexNet Embedded FlexNet Publisher FlexNet Connect FlexNet Code Insight InstallAnywhere InstallShield |
North America * |
+1 630-332-2513 (toll) +1 877-279-2853 (toll-free in North America) |
| Europe * |
+44 1925 944367 (toll) +44 800 047 8642 (toll-free in Europe) |
|
| Japan * | +81 3-4540-5335 (select option 2) | |
| Australia * |
+61 3 9895 2177 +61 1800 560 603 (toll-free in Australia) |
|
|
Usage Intelligence (formerly
Revulytics) Compliance Intelligence |
Please use the Case Portal to submit your support ticket or reach out to your Revenera contact. | |
Case id: 00001065
Activity: Status change: 2 hours ago