Often an app needs to be checked and/or uninstalled quickly or less quickly. This can be the case when a built-in app installs a component that is actually not wanted. I have made an example script here, which uses the Proactive Remediation of Endpoint Manager (MEM). I will not go into detail what MEM or Proactive Remediation is. Only, use Proactive Remediation :-)!
No matter if you use MEM or MEMCM, you will surely know the uninstall string of an app in the registry. I use this to query the details of the app. This has the advantage, if a version changes or is not 100% identical with the same parameters, that the remove still works.
So first I query the registry and search for the app in the uninstall keys. In this case I know that it was registered in the WOW6432Node. In this example it is about the “Intel Driver & Support Assistant”. As this software uses a new GUID for new versions, it make sense not to use the GUID as a parameter, only if you like to uninstall a specific version this maybe make sense.

DETECTION
Getting the app details. For sure you could use any property of the $appdtails to query. In my case I use the “InstallLocation” and the “DisplayName”
$appdetails = (Get-ItemProperty Registry::HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*) | Where-Object {$_.InstallLocation -eq "C:\Program Files (x86)\Intel\Driver and Support Assistant\" -and $_.DisplayName -eq "Intel Driver && Support Assistant"}
In a second detection step you can check if the app is present or not. If not,
Exit 0 is used. If available exit 1 is used. Exit 1 forces the remediation.
try {
if ($appdetails.DisplayName -eq "Intel Driver && Support Assistant"){
Write-Output "Intel Driver & Support Assistant is installed and will now be removed"
Exit 1
}
else {
Write-Output "Intel Driver & Support Assistant is not installed. No action required"
Exit 0
}
}
catch{
$errMsg = $_.exeption.essage
Write-Output $errMsg
}
REMEDIATION
Now lets go to the remediation. As soon as the detection script is terminated with exit 1, the remediation script is started.
First I start with a view parameters such as argumentlist. This details can also be found in the regkey or our variable $appdetails. Again, I check the app details:
param (
[string]$msiname ="Intel Driver and Support Assistant Installer.msi",
[string]$pathsw = $appdetails.InstallLocation,
[string]$argumentlist = "/X" + $appdetails.PSChildName + " /qn" + " /noreboot",
[string]$uninstallsource = $appdetails.InstallSource + $msiname
)
$appdetails = (Get-ItemProperty Registry::HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*) | Where-Object {$_.InstallLocation -eq "C:\Program Files (x86)\Intel\Driver and Support Assistant\" -and $_.DisplayName -eq "Intel Driver && Support Assistant"}
Then I create a new region block with the remediation to uninstall the app. This is done with the start-process command.
#region Uninstalling Intel Driver & Support Assistant
try {
if ($appdetails.DisplayName -eq "Intel Driver && Support Assistant") {
Start-Process "msiexec.exe" -ArgumentList $argumentlist -Wait -NoNewWindow
Write-Output "Intel Driver & Support Assistant removed"
exit 0
}
else
{
Write-Output "Intel Driver & Support Assistant is not installed. No action required"
exit 0
}
}
catch{
$errMsg = $_.exeption.essage
Write-Output $errMsg
}
#endregion
PUTTING ALL TOGETHER
Save both scripts so that they can be imported into the MEM. Under endpoint.microsoft.com – Reports – Proactive Remediation create a new script package and use the following properties:
Name: Detect and remediate Intel Driver & Support Assistant (or similar)
Settings: Detection script – select your saved detection script
Settings: Remediation script – select your saved remediation script
Run script in 64-bit PowerShell: Yes
Assignments: Select a group, all devices and/or filters (I love filters)
Schedule: I use “Hourly”, Repeats every hour
Deploy the package to your devices. As soon as the client has made an agent update via IME, the script packages will be executed and reports back to Endpoint Analytics.

To get more insights, use the “Columns” View. This will show you the Write-Output messages we have defined in the script earlier.

For example the Pre-remediation output message:

Let me know if this was helpful or leave a comment if you have any questions.