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.

Name of the property to retrieve. Property names are case-sensitive.

String, the property value. Returns an empty string if the property isn’t set in the MSI. Returns $null, without throwing an error, if the MSI file doesn’t exist or can’t be opened.

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

Terminal window
$msiFile = Join-Path $global:Packageroot "kit\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 "kit\pdfsam.msi"
$kitVersion = [version]$cs.MSI_GetPropertyFromMSI($msiFile, "ProductVersion")
$iniFile = "$env:ProgramData\Contoso\App\settings.ini"
if ($cs.File_ExistFile($iniFile)) {
$installedVersion = $cs.Ini_ReadEntry($iniFile, "app", "installedVersion")
if ($installedVersion -and ([version]$installedVersion -ge $kitVersion)) {
Exit-PSScript -exitcode 3330 -exitmessage "Installed version $installedVersion is already up to date, skipping install"
}
}

$cs.MSI_GetPropertiesFromMSI