Skip to content

Instantly share code, notes, and snippets.

@bjh1977
Created October 8, 2018 10:24
Show Gist options
  • Save bjh1977/c36be228c6865dd414df13a8703e3cb6 to your computer and use it in GitHub Desktop.
Save bjh1977/c36be228c6865dd414df13a8703e3cb6 to your computer and use it in GitHub Desktop.
$path = "\\path\to\file\msoidcli_64bit.msi"
$comObjWI = New-Object -ComObject WindowsInstaller.Installer
$MSIDatabase = $comObjWI.GetType().InvokeMember("OpenDatabase","InvokeMethod",$Null,$comObjWI,@($Path,0))
$Query = "SELECT Value FROM Property WHERE Property = 'ProductCode'"
$View = $MSIDatabase.GetType().InvokeMember("OpenView","InvokeMethod",$null,$MSIDatabase,($Query))
$View.GetType().InvokeMember("Execute", "InvokeMethod", $null, $View, $null)
$Record = $View.GetType().InvokeMember("Fetch","InvokeMethod",$null,$View,$null)
$Value = $Record.GetType().InvokeMember("StringData","GetProperty",$null,$Record,1)
$Value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment