Use Power to get MSI Properties

Read a great post today by Nickolaj regarding reading MSI packages in powershell:

I had developed some earlier scripts a while back for reading MSI packages in powershell, but the scripts were … well … ugly, with an external COM xml type library.

Nickolaj’s script got me thinking how to improve my version, so I updated it and will post here:

The main difference between my version and the one by Nickolaj, is that this script will return all Properties, rather than only those properties requested when calling. This helps in discovery of available properties.

[ValidateScript({Test-Path $_})]

$WindowsInstaller = New-Object -com WindowsInstaller.Installer
$MSIDatabase = $WindowsInstaller.GetType().InvokeMember(

$View = $MSIDatabase.GetType().InvokeMember(
$MSIDatabase,"SELECT * FROM Property")

"Execute", "InvokeMethod", $null, $View, $null)
while($Record = $View.GetType().InvokeMember(
@{ $Record.GetType().InvokeMember(
"StringData","GetProperty",$null,$Record,1) =


Now, Why would you want to look at the properties of a MSI package?

Well, say you installed an application package into your Windows Install.wim image. However, you might want to try re-installing the same application package during deploy time. How to ensure that you don’t try to re-run the installation for the same package again if installed.

Well ZTIApplications in MDT can leverage the MSI Product Code. IT will check the registry for the MSI Product Code, and skip over the installation if present.

Just ensure that the product code is set in the application package as the uninstall key name:




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s