$cs.MSI_IsMSIGuidInstalled
Description
Section titled “Description”Checks whether a product with the given ProductCode GUID is currently installed, by querying Windows Installer’s product state directly — no MSI file needed, just the GUID. Windows-only.
A product counts as installed when Windows Installer reports it as fully installed for the machine, or for the account that runs the PowerPack. Products that are only advertised, or installed per-user for another user, return $false.
Syntax
Section titled “Syntax”$cs.MSI_IsMSIGuidInstalled(string msiguid)
Parameters
Section titled “Parameters”msiguid (String)
Section titled “msiguid (String)”ProductCode GUID to check the installation status of.
Return value
Section titled “Return value”Boolean, $true if a product with this GUID is installed. Returns $false on any error rather than throwing.
Example
Section titled “Example”if ($cs.MSI_IsMSIGuidInstalled('{AC76BA86-1033-FF00-7760-BC15014EA700}')) { $cs.Job_WriteLog("Product is already installed, skipping install")}Use the same guard with a hardcoded GUID inside PreInstall, which is useful because the kit folder, and the MSI in it, isn’t downloaded until after PreInstall has run:
function PreInstall { $cs.Log_SectionHeader('PreInstall', 'o') $knownProductCode = '{AC76BA86-1033-FF00-7760-BC15014EA700}' if ($cs.MSI_IsMSIGuidInstalled($knownProductCode)) { Exit-PSScript -exitcode 3330 -exitmessage "$global:AppName ($knownProductCode) is already installed, nothing to do" }}