windowspowershellinstallationcomobject

PowerShell Windows Installer Com Object


I'm trying to modify the contents of an MSI file using Powershell. To do so I create an instance of a WindowsInstaller.Installer then use $installer.OpenDatabase and $database.OpenView. Similar functionality works in VBScript and I've seen samples on-line that appear to work.

$installer = new-object -comobject "WindowsInstaller.Installer"
$database = $installer.OpenDatabase("C:\Temp\Setup.msi", 1)

For the above code, I get an error "Method invocation failed because [System.__ComObject] doesn't contain a method named 'OpenDatabase'."

$installer = new-object -comobject "WindowsInstaller.Installer"
$database = $installer.InvokeMethod("OpenDatabase","C:\Temp\Setup.msi", 1)

If I attempt to use $installer.InvokeMethod I get the same error "Method invocation failed because [System.__ComObject] doesn't contain a method named 'InvokeMethod'."

Any help would be much appreciated.

Thanks.


Solution

  • See the this thread for some guidance. Basically the MSI COM object is implemented in a way that confuses PS. There is a link to a blog post discussing it in that thread.