Up 1 Down 0

Extract product GUID from msi

RemoteDesktop_1.2.6187.0_x64.msi example.
Replace C:\IntunePackage\Source\RemoteDesktop_1.2.6187.0_x64.msi:

$windowsInstaller = New-Object -ComObject WindowsInstaller.Installer
$database = $windowsInstaller.GetType().InvokeMember("OpenDatabase", "InvokeMethod", $null, $windowsInstaller, @("C:\IntunePackage\Source\RemoteDesktop_1.2.6187.0_x64.msi", 0))
$query = "SELECT `Value` FROM `Property` WHERE `Property` = 'ProductCode'"
$view = $database.GetType().InvokeMember("OpenView", "InvokeMethod", $null, $database, @($query))
$view.GetType().InvokeMember("Execute", "InvokeMethod", $null, $view, $null)
$record = $view.GetType().InvokeMember("Fetch", "InvokeMethod", $null, $view, $null)
$productCode = $record.GetType().InvokeMember("StringData", "GetProperty", $null, $record, 1)
Write-Output "Product Code: $productCode"