Do X if application already installed

First time using the toolkit.

I have a pretty basic MSI install (Wazuh Agent) I have running using the kit. Installs and uninstalls well enough silently.
There is an additional post-installation task of linking this agent to a manager server that I can get to work using the built-in Execute-Process command and giving it some string parameters. This achieves some of the link and groups with something like If ((Get-ComputerInfo).CSModel -eq X) {Execute-Process -Path X -Parameters X}

I am running into an issue where I can’t get the post-install task to run from SCCM if the application is already installed (detection rule picks it up) and picked up by Config Manager. I have tried outputting a file during the install and testing, however the toolkit also senses the MSI already installed and skips over my command entirely. Outputs something like MSI already installed, skipping to post-installation. Which obviously doesn’t output the file for the detection rule.

Can anyone help me figure this out?

You have a couple of options, the Execute-MSI cmdlet has the ‘-SkipMSIAlreadyInstalledCheck’ switch which allows Execute-MSI to proceed even if the MSI is already installed. Another option would be to use the Get-InstalledApplications cmdlet to see of the application is already installed and perform actions accordingly.

In terms of detection I like to use registry keys where to ensure additional steps are performed after the application is installed that aren’t easily detectable using File or Registry detection methods. I create a Registry Key with our organisations name under HKLM and place any additional detection info required there eg.


If you need to make changes to the configuration you can simply bump the version number to 2,3 etc.

The last step in my script is to set the registry key, that way if there are failures before the script completes the registry key is not set and the detection fails.

1 Like

I didn’t even see the -SkipMSIAlreadyInstalledCheck cmdlet switch! That combined with a quick registry key fixes my issue. Thanks @gtaylor!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.