PowerShell Windows Installer Com Object

Question:

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.

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

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.

Answer:

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.

Source:

PowerShell Windows Installer Com Object by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply