Skip to content

Get MsiFileInfo

Raymond Piller edited this page Feb 28, 2019 · 12 revisions

Get properties out of MSI file.

Description

This function will read the properties out of an MSI file without locking the specified file. The following properties are always returned even if you specify a list of properties.

  • Manufacturer
  • ProductName
  • ProductVersion
  • ProductCode
  • ProductLanguage
  • FullVersion

If you don't see this in the output, it's likely not included in the Properties table. These cannot be removed from what's returned; it's meant to work a lot like ActiveDirectory's Get-ADUser or Get-ADComputer cmdlets.

Additionally, the MSI file's [IO.FileInfo] is returned as the .IO.FileInfo property. This was deemed a safe naming convention for this meta data because of the leading period. Although periods (.) are allowed in an MSI's property name, property names cannot begin with a period.

Demo output (from default example):

.IO.FileInfo    : C:\Temp\SurfaceBook_Win10_15063_1802100_0.msi
Manufacturer    : Microsoft
ProductCode     : {1CD69D1F-0C2D-46A0-89A9-F29582DC718F}
ProductLanguage : 1033
ProductName     : SurfaceBook Update 18_021_00 (64 bit)
ProductVersion  : 18.021.18206.0

Parameters

Path

  • Required
  • [IO.FileInfo]
  • Can be value from pipeline.

The path to the MSI file that will be queried.

See any of the examples.

Properties

  • [string[]]
  • Default: @('Manufacturer', 'ProductName', 'ProductVersion', 'ProductCode', 'ProductLanguage', 'FullVersion')

The default properties are always returned even if you specify a list of different properties. If you don't see a default property or one your requested in the list of returned properties, it's likely not included in the MSI's Properties table. The default properties cannot be removed from what's returned; it's meant to work a lot like ActiveDirectory's Get-ADUser or Get-ADComputer cmdlets.

Additionally, the MSI file's [IO.FileInfo] is returned as the .IO.FileInfo property. This was deemed a safe naming convention for this meta data because of the leading period. Although periods (.) are allowed in an MSI's property name, property names cannot begin with a period.

See the One Property, Two Or More Properties, Property That Does Not Exist, or All Properties examples.

GetPublicProperties

  • [switch]

Setting this will negate the Properties parameter.

The values of public properties can be changed by a user or system administrator by setting the property on the command line, by applying a transform, or by interacting with an authored user interface.

See the Get Public Properties example.

Ref: https://docs.microsoft.com/en-us/windows/desktop/msi/public-properties

DoNotIncludeFileInfo

  • [switch]

By default, this function will return the [System.IO.FileInfo] for the MSI file being queried as the .IO.FileInfo property. This is a safe naming convention because MSI property names cannot begin with a period.

See the Do Not Include File Info example.

IncludeNonMsiFileInfo

  • [switch]

By default, this function will not return the [System.IO.FileInfo] for the non-MSI files that are encountered. If you have the DoNotIncludeFileInfo parameter set, this parameter will be negated.

See the Non-MSI Files Can Be Returned With Warning example.

Examples

For these examples, there are three MSI files in C:\Temp:

PS C:\Temp> dir

    Directory: C:\Temp

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----       10/28/2018  10:31 AM      921993216 SurfaceBook_Win10_15063_1802100_0.msi
-a----       10/28/2018  10:31 AM      995303424 SurfaceBook_Win10_16299_1802300_1.msi
-a----       10/28/2018  10:28 AM      502902784 SurfaceBook_Win10_1701000_0.msi
-a----        2/25/2019  10:18 AM              0 tmp9D9A.tmp

Default Properties

Get-MsiFileInfo -Path 'C:\Temp\SurfaceBook_Win10_15063_1802100_0.msi'

Output:

.IO.FileInfo    : C:\Temp\SurfaceBook_Win10_15063_1802100_0.msi
Manufacturer    : Microsoft
ProductCode     : {1CD69D1F-0C2D-46A0-89A9-F29582DC718F}
ProductLanguage : 1033
ProductName     : SurfaceBook Update 18_021_00 (64 bit)
ProductVersion  : 18.021.18206.0

Default Properties; Path From Pipeline

Get-ChildItem -LiteralPath 'C:\Temp' -Filter '*.msi' -Recurse | Get-MsiFileInfo

Output:

.IO.FileInfo    : C:\Temp\SurfaceBook_Win10_15063_1802100_0.msi
Manufacturer    : Microsoft
ProductCode     : {1CD69D1F-0C2D-46A0-89A9-F29582DC718F}
ProductLanguage : 1033
ProductName     : SurfaceBook Update 18_021_00 (64 bit)
ProductVersion  : 18.021.18206.0

.IO.FileInfo    : C:\Temp\SurfaceBook_Win10_16299_1802300_1.msi
Manufacturer    : Microsoft
ProductCode     : {F09FF86C-CA9E-49BE-91D0-50FD0A3A1201}
ProductLanguage : 1033
ProductName     : SurfaceBook Update 18_023_00 (64 bit)
ProductVersion  : 18.023.18203.0

.IO.FileInfo    : C:\Temp\SurfaceBook_Win10_1701000_0.msi
Manufacturer    : Microsoft Corporation
ProductCode     : {7B75853B-4AE5-4593-8C97-942A206D2F5D}
ProductLanguage : 1033
ProductName     : Surface Platform Installer
ProductVersion  : 17.010.00.0

One Property

This adds it to the list of properties.

Get-MsiFileInfo -Path 'C:\Temp\SurfaceBook_Win10_15063_1802100_0.msi' -Properties UpgradeCode

Output:

.IO.FileInfo    : C:\Temp\SurfaceBook_Win10_15063_1802100_0.msi
UpgradeCode     : {C9ECCDE4-9532-4242-8D2E-2CC92C267765}
Manufacturer    : Microsoft
ProductCode     : {1CD69D1F-0C2D-46A0-89A9-F29582DC718F}
ProductLanguage : 1033
ProductName     : SurfaceBook Update 18_021_00 (64 bit)
ProductVersion  : 18.021.18206.0

Two Or More Properties

Get-MsiFileInfo -Path 'C:\Temp\SurfaceBook_Win10_15063_1802100_0.msi' -Properties UpgradeCode,ALLUSERS

Output:

.IO.FileInfo    : C:\Temp\SurfaceBook_Win10_15063_1802100_0.msi
UpgradeCode     : {C9ECCDE4-9532-4242-8D2E-2CC92C267765}
ALLUSERS        : 1
Manufacturer    : Microsoft
ProductCode     : {1CD69D1F-0C2D-46A0-89A9-F29582DC718F}
ProductLanguage : 1033
ProductName     : SurfaceBook Update 18_021_00 (64 bit)
ProductVersion  : 18.021.18206.0

Property That Does Not Exist

If you request a property that doesn't exist, it won't be returned in the query results. No error will be thrown.

Get-MsiFileInfo -Path 'C:\Temp\SurfaceBook_Win10_15063_1802100_0.msi' -Properties PropertyThatDoesNotExist

Output:

.IO.FileInfo    : C:\Temp\SurfaceBook_Win10_15063_1802100_0.msi
Manufacturer    : Microsoft
ProductCode     : {1CD69D1F-0C2D-46A0-89A9-F29582DC718F}
ProductLanguage : 1033
ProductName     : SurfaceBook Update 18_021_00 (64 bit)
ProductVersion  : 18.021.18206.0

All Properties

Get-MsiFileInfo -Path 'C:\Temp\SurfaceBook_Win10_15063_1802100_0.msi' -Properties *

All three methods of calling supported

.IO.FileInfo           : C:\Temp\SurfaceBook_Win10_15063_1802100_0.msi
UpgradeCode            : {C9ECCDE4-9532-4242-8D2E-2CC92C267765}
WixUIRMOption          : UseRM
WIXUI_INSTALLDIR       : INSTALLFOLDER
ALLUSERS               : 1
ARPNOMODIFY            : 1
ARPNOREPAIR            : 1
InstallPrerequisites   : OSVersion=Win10;ProductName=SurfaceBook;SystemSKU=;OSBuild=15063;SystemModels=Surface
                         Book;SystemSKUs=;PreventBitLockerNoSecureBoot=0
ARPCONTACT             : http://www.surface.com
ARPURLINFOABOUT        : http://www.surface.com
ARPHELPLINK            : https://www.surface.com/support
DISABLEROLLBACK        : 1
Manufacturer           : Microsoft
ProductCode            : {1CD69D1F-0C2D-46A0-89A9-F29582DC718F}
ProductLanguage        : 1033
ProductName            : SurfaceBook Update 18_021_00 (64 bit)
ProductVersion         : 18.021.18206.0
DefaultUIFont          : WixUI_Font_Normal
WixUI_Mode             : InstallDir
ErrorDialog            : ErrorDlg
SecureCustomProperties : WIX_DOWNGRADE_DETECTED;WIX_UPGRADE_DETECTED

Get Public Properties

Get-MsiFileInfo -Path 'C:\Temp\SurfaceBook_Win10_15063_1802100_0.msi' -GetPublicProperties

Output:

.IO.FileInfo     : C:\Temp\SurfaceBook_Win10_15063_1802100_0.msi
WIXUI_INSTALLDIR : INSTALLFOLDER
ALLUSERS         : 1
ARPNOMODIFY      : 1
ARPNOREPAIR      : 1
ARPCONTACT       : http://www.surface.com
ARPURLINFOABOUT  : http://www.surface.com
ARPHELPLINK      : https://www.surface.com/support
DISABLEROLLBACK  : 1
Manufacturer     : Microsoft
ProductCode      : {1CD69D1F-0C2D-46A0-89A9-F29582DC718F}
ProductLanguage  : 1033
ProductName      : SurfaceBook Update 18_021_00 (64 bit)
ProductVersion   : 18.021.18206.0

Do Not Include File Info

Get-MsiFileInfo -Path 'C:\Temp\SurfaceBook_Win10_15063_1802100_0.msi' -DoNotIncludeFileInfo

Output:

Manufacturer    : Microsoft
ProductCode     : {1CD69D1F-0C2D-46A0-89A9-F29582DC718F}
ProductLanguage : 1033
ProductName     : SurfaceBook Update 18_021_00 (64 bit)
ProductVersion  : 18.021.18206.0

MSI Does Not Exist

Get-MsiFileInfo -Path 'C:\Temp\DoesNotExist.msi'

Output:

.IO.FileInfo
------------
C:\Temp\DoesNotExist.msi

This can be drilled into a bit further:

PS C:\Temp> $foo = Get-MsiFileInfo -Path 'C:\Temp\DoesNotExist.msi'
PS C:\Temp> $foo.'.IO.FileInfo'.Exists
False

Non-MSI Files Are Skipped With Warning

When a non-MSI file is encountered, it is normally skipped with a warning and nothing is returned.

Get-ChildItem -LiteralPath 'C:\Temp' -Recurse | Get-MsiFileInfo

Output:

.IO.FileInfo    : C:\Temp\SurfaceBook_Win10_15063_1802100_0.msi
Manufacturer    : Microsoft
ProductCode     : {1CD69D1F-0C2D-46A0-89A9-F29582DC718F}
ProductLanguage : 1033
ProductName     : SurfaceBook Update 18_021_00 (64 bit)
ProductVersion  : 18.021.18206.0

.IO.FileInfo    : C:\Temp\SurfaceBook_Win10_16299_1802300_1.msi
Manufacturer    : Microsoft
ProductCode     : {F09FF86C-CA9E-49BE-91D0-50FD0A3A1201}
ProductLanguage : 1033
ProductName     : SurfaceBook Update 18_023_00 (64 bit)
ProductVersion  : 18.023.18203.0

.IO.FileInfo    : C:\Temp\SurfaceBook_Win10_1701000_0.msi
Manufacturer    : Microsoft Corporation
ProductCode     : {7B75853B-4AE5-4593-8C97-942A206D2F5D}
ProductLanguage : 1033
ProductName     : Surface Platform Installer
ProductVersion  : 17.010.00.0

WARNING: Unable to open MSI database; it's either not an MSI file or the file is corrupted: C:\Temp\tmp9D9A.tmp

Non-MSI Files Can Be Returned With Warning

When a non-MSI file is encountered, it is normally skipped with a warning and nothing is returned. However, if the IncludeNonMsiFileInfo parameter is supplied, the .IO.FileInfo will be returned with the warning message.

Get-ChildItem -LiteralPath 'C:\Temp' -Recurse | Get-MsiFileInfo -IncludeNonMsiFileInfo

Output:

.IO.FileInfo    : C:\Temp\SurfaceBook_Win10_15063_1802100_0.msi
Manufacturer    : Microsoft
ProductCode     : {1CD69D1F-0C2D-46A0-89A9-F29582DC718F}
ProductLanguage : 1033
ProductName     : SurfaceBook Update 18_021_00 (64 bit)
ProductVersion  : 18.021.18206.0

.IO.FileInfo    : C:\Temp\SurfaceBook_Win10_16299_1802300_1.msi
Manufacturer    : Microsoft
ProductCode     : {F09FF86C-CA9E-49BE-91D0-50FD0A3A1201}
ProductLanguage : 1033
ProductName     : SurfaceBook Update 18_023_00 (64 bit)
ProductVersion  : 18.023.18203.0

.IO.FileInfo    : C:\Temp\SurfaceBook_Win10_1701000_0.msi
Manufacturer    : Microsoft Corporation
ProductCode     : {7B75853B-4AE5-4593-8C97-942A206D2F5D}
ProductLanguage : 1033
ProductName     : Surface Platform Installer
ProductVersion  : 17.010.00.0

WARNING: Unable to open MSI database; it's either not an MSI file or the file is corrupted: C:\Temp\tmp9D9A.tmp
.IO.FileInfo : C:\Temp\tmp9D9A.tmp

Notes