PowerShell Windows Installer Com Object

I am trying to modify the contents of an MSI file using Powershell. To do this, I create an instance of WindowsInstaller.Installer, then use $ installer.OpenDatabase and $ database.OpenView. Similar functionality works in VBScript, and I saw samples online that seem to work.

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

For the above code, I get the error message "Method call failed because [System .__ ComObject] does not contain a method called" OpenDatabase. "

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

If I try to use $ installer.InvokeMethod, I get the same "Method Error" error because [System .__ ComObject] does not contain a method called "InvokeMethod".

Any help would be greatly appreciated.

Thanks.

+4
source share
2 answers

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

+3
source

The originally accepted response link is no longer valid.

In the comments, JohnB posted a link that provides a great example of using the Windows Installer from Powershell.

There is also a CodePlex project that provides more functionality and can be useful:
Windows Installer PowerShell Installation Module

+2
source

All Articles