Skip to content

$cs.MSI_GetPropertyFromMSI

Reads a single named property (e.g. "ProductVersion", "ProductName", "Manufacturer", "ProductCode") from an MSI file’s internal property table. Windows-only.

$cs.MSI_GetPropertyFromMSI(string msifile, string property)

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

Name of the property to retrieve.

String, the property value, or $null if the property isn’t set in the MSI.

Read the ProductVersion from the kit’s MSI simply to log it:

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

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

$cs.MSI_GetPropertiesFromMSI