$cs.MSI_GetPropertiesFromMSI
Description
Section titled “Description”Reads several named properties from an MSI file at once. Windows-only.
Syntax
Section titled “Syntax”$cs.MSI_GetPropertiesFromMSI(string msifile, Array property)
Parameters
Section titled “Parameters”msifile (String)
Section titled “msifile (String)”Path to the MSI file to read from.
property (Array)
Section titled “property (Array)”Array of property names to retrieve, e.g. @("ProductCode","ProductVersion"). Property names are case-sensitive.
Return value
Section titled “Return value”Hashtable keyed by property name. A property that isn’t set in the MSI gets an empty string as its value.
Returns $null, without throwing an error, if the property array is empty or null, or if the MSI file doesn’t exist or can’t be opened. Always check the result for $null before you use it.
Example
Section titled “Example”Read several MSI properties up front and store them in globals for later use throughout the script:
$msiFile = Join-Path $global:Packageroot "kit\pdfsam.msi"$msiProperties = $cs.MSI_GetPropertiesFromMSI($msiFile, @("ProductVersion","UpgradeCode","ProductCode","ProductName","Manufacturer"))if ($msiProperties) { [string]$global:Msiproductversion = $msiProperties["ProductVersion"] [string]$global:Msiupgradecode = $msiProperties["UpgradeCode"] [string]$global:Msiproductcode = $msiProperties["ProductCode"] [string]$global:MsiProductName = $msiProperties["ProductName"] [string]$global:MsiManufacturer = $msiProperties["Manufacturer"]}Read just ProductCode and ProductVersion together for a single inventory-style log line:
$msiFile = Join-Path $global:Packageroot "kit\pdfsam.msi"$props = $cs.MSI_GetPropertiesFromMSI($msiFile, @("ProductCode","ProductVersion"))if ($props) { $cs.Job_WriteLog("Deploying ProductCode $($props['ProductCode']), version $($props['ProductVersion'])")}