In this post we discuss how to enable implicit uninstalls in SCCM using PowerShell and WMI.
There are certain prerequisites for implicit uninstalls to work:
- You need to be running at least version 2107 of SCCM (MECM)
- You need to be using device collections and not user collections
- Your deployment must be a ‘required’ deployment
- You must also specify an uninstall command.
But the setting….or checkbox, we are looking to amend can be seen below. Navigate to your application, and then under the ‘Deployments’ tab you can right-click your assignment, choose Properties and then select the ‘Deployment Settings’ tab:
Enable Implicit Uninstalls in SCCM Using PowerShell
The challenge at the moment is that the Set-CMApplicationDeployment PowerShell cmdlet does NOT support updating the implicit uninstall flag. So the only alternative is to use WMI and the SMS_ApplicationAssignment class. And there are two properties we need to set – OfferFlags (which is semi-documented) and AdditionalProperties (which is undocumented).
OfferFlags is only semi-documented because it is missing a flag – guess which one? You guessed it – the implicit uninstall flag!
Value | Offer flag |
---|---|
1 | PREDEPLOY |
2 | ONDEMAND |
4 | ENABLEPROCESSTERMINATION |
8 | ALLOWUSERSTOREPAIRAPP |
16 | RELATIVESCHEDULE |
32 | HIGHIMPACTDEPLOYMENT |
64 | IMPLICITUNINSTALL |
And AdditionalProperties is a string of XML which appears to be similar to this:
The important node for this exercise is obviously ImplicitUninstallEnabled.
Since we need to update the assignment (deployment), in my scenario I will update the assignment by its ID since i know it will be unique. I can find the ID for all of my assignments like so:
Note that the function below is still in test mode, so I’m not going to run it for every deployment above! I will test it on a single application to begin with, in my dev environment since it’s probably not officially supported by Microsoft!
I have obtained the assignment ID of 16778268 and can now call the function like so:
In the script above there’s a cool (in a geeky way) example of how to use PowerShell to calculate bit flags too, which will come in very useful when I’m inspecting Windows Installer objects.