$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.
property (String)
Section titled “property (String)”Name of the property to retrieve. Property names are case-sensitive.
Return value
Section titled “Return value”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.
Example
Section titled “Example”Read the ProductVersion from the kit’s MSI simply to log it:
$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:
$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" }}