Skip to content

$cs.MSI_GetPropertiesFromMSI

Reads several named properties from an MSI file at once. Windows-only.

$cs.MSI_GetPropertiesFromMSI(string msifile, Array property)

Path to the MSI file to read from. Throws a FileNotFoundException if this file doesn’t exist.

Array of property names to retrieve, e.g. @("ProductCode","ProductVersion").

Hashtable keyed by property name, or $null if the property array is empty or null.

Read several MSI properties up front and store them in globals for later use throughout the script:

Terminal window
$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:

Terminal window
$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'])")
}

$cs.MSI_GetPropertyFromMSI