$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. Throws a FileNotFoundException if this file doesn’t exist.
property (Array)
Section titled “property (Array)”Array of property names to retrieve, e.g. @("ProductCode","ProductVersion").
Return value
Section titled “Return value”Hashtable keyed by property name, or $null if the property array is empty or null.
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 "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 "pdfsam.msi"$props = $cs.MSI_GetPropertiesFromMSI($msiFile, @("ProductCode","ProductVersion"))if ($props) { $cs.Job_WriteLog("Deploying ProductCode $($props['ProductCode']), version $($props['ProductVersion'])")}