-
Notifications
You must be signed in to change notification settings - Fork 0
Get MsiFileInfo
Get properties out of MSI file.
Table of Contents |
---|
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
Note: 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.
Note: Additionally, the MSI file's [IO.FileInfo]
is returned as the .IO.FileInfo
property.
[IO.FileInfo]
The path to the MSI file that will be queried.
[string[]]
-
Default:
@('Manufacturer', 'ProductName', 'ProductVersion', 'ProductCode', 'ProductLanguage', 'FullVersion')
The default properties are always returned even if you specify a list of 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.
[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.
Ref: https://docs.microsoft.com/en-us/windows/desktop/msi/public-properties
[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.
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
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
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
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
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
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
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-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
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
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
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
.IO.FileInfo : C:\Temp\tmp9D9A.tmp
- Code adapted from @NickolajA's
Get-MSIFileInformation.ps1
.