Share via


How To Auto Uninstall User Device Affinity Applications in Configuration Manager 2012

Before Christmas, a colleague came to me with a customer scenario where they were leveraging User Device Affinity to pre-deploy software installations to users, however they were looking for a method to automatically uninstall the software when either a user’s device affinity changed or the application was revoked.

The application virtualisation white paper discusses methods for auto uninstall, however user policy through UDA will block any uninstallations from occurring. But an uninstall deployment to a machine that installed software through a User targeted installed initially returns “rule is in conflict with other rules” and never re-evaluates to do the uninstall.

So the question remained, how to handle automatic uninstall for user based deployments that leverage the “Pre-deploy software to the user’s primary device”.

 

My solution to get around this was to create 3 collections:

1) The target collection – this is the collection of users that require the software and to which the deployment is advertised.

2) A collection for each user targeted application that infers the machines that have been targeted due to User Device Affinity.

3) A third that contains either an inverse of all machines not in collection 2 (ie machines that are not targeted for the application) or all machines that have the software that are not in collection 2 – the latter of which will rely on either deployment status messages or hardware inventory.

The query for collection 2 is as follows:

select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_UserMachineRelationship on SMS_UserMachineRelationship.ResourceId = SMS_R_System.ResourceId where SMS_UserMachineRelationship.UniqueUserName in ( select SMSID from SMS_CM_RES_COLL_PRI001D8 ) and SMS_UserMachineRelationship.IsActive != '0'

 Where PRI001D8 is the user collection in step 1 and SMS_UserMachineRelationship.IsActive != '0' handles the revocation of affinity between a user and a machine.

Then target the uninstall deployment at collection 3 and whenever the affinity for a user changes the affected machine will receive an uninstall policy and there will be no conflict to stop it from running

 

Rob York
Premier Field Engineer

Comments

  • Anonymous
    July 14, 2016
    Rob,Thank you for your post, it sounds like what we are looking to do, however do you have any other examples to clarify the process? We ran the first two queries and the systems listed in the second one did not match the 1st collection's members. Any help is appreciated.