Skip to content

$cs.MSI_IsMSIGuidInstalled

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.

$cs.MSI_IsMSIGuidInstalled(string msiguid)

ProductCode GUID to check the installation status of.

Boolean, $true if a product with this GUID is installed. Returns $false on any error rather than throwing.

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

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

$cs.MSI_GetProductCodeFromMSI $cs.MSI_IsMSIFileInstalled