$cs.MSI_GetPropertyFromMSI
Description
Section titled “Description”Reads a single named property (e.g. "ProductVersion", "ProductName", "Manufacturer", "ProductCode") from an MSI file’s internal property table. Windows-only.
Syntax
Section titled “Syntax”$cs.MSI_GetPropertyFromMSI(string msifile, string 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 (String)
Section titled “property (String)”Name of the property to retrieve.
Return value
Section titled “Return value”String, the property value, or $null if the property isn’t set in the MSI.
Example
Section titled “Example”Read the ProductVersion from the kit’s MSI simply to log it:
$msiFile = Join-Path $global:Packageroot "pdfsam.msi"$msiProductVersion = $cs.MSI_GetPropertyFromMSI($msiFile, "ProductVersion")$cs.Job_WriteLog("MSI ProductVersion: $msiProductVersion")Compare the kit’s ProductVersion against a version already recorded on the machine, and skip installation if it’s not newer:
$msiFile = Join-Path $global:Packageroot "pdfsam.msi"$kitVersion = [version]$cs.MSI_GetPropertyFromMSI($msiFile, "ProductVersion")$installedVersion = [version]$cs.Ini_ReadEntry("$env:ProgramData\Contoso\App\settings.ini", "app", "installedVersion")if ($installedVersion -and ($installedVersion -ge $kitVersion)) { $cs.Job_WriteLog("Installed version $installedVersion is already up to date, skipping install")}