This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Knowledge Base
- :
- How to Use PowerShell to Retrieve Info from an .msi
Subscribe
- Mark as New
- Mark as Read
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
How to Use PowerShell to Retrieve Info from an .msi
How to Use PowerShell to Retrieve Info from an .msi
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
No ratings