Search code examples
powershellcom

powershell com object windows installer


I would like to leverage the following

$wi=new-object -com WindowsInstaller.Installer

If I do a $wi |gm I do not see the method I want "Products". I would like to iterate Products and show a list of all items installed on the system.

So I thought... let me do a $wi.gettype().invokemember

Not really sure what to do $wi.gettype().invokemember("Products","InvokeMethod") or something yields cannot find an overload...

But now I am lost. I have looked elsewhere but I don't want to create a whole XML file. I should be able to access the com objects methods.


Solution

    1. If you are trying to get a list of installed programs in Windows, there is a native Powershell way, which is actually using WMI behind the scenes:

      Get-WmiObject Win32_Product
      

      Here's a related article from Microsoft Scripting Guys.

      It appears that this approach has some issues, so better be avoided.

      When you query this class, the way the provider works is that it actually performs a Windows Installer “reconfiguration” on every MSI package on the system as its performing the query!

    2. I tried my best to find a solution that involves WindowsInstaller com object, but all of them point to an article that no longer exists. Here is one on stackoverflow.

    3. An alternative solution is to give a try to psmsi on CodePlex.