The below script will automaticcaly uninstall software if user is no longer member of the group, and the software is installed on the computer.
replace Software Installed with your software display name and “DOMAIN\\GROUP” with your local security group that is used for installing the software
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_G_System_ADD_REMOVE_PROGRAMS on
SMS_G_System_ADD_REMOVE_PROGRAMS.ResourceID = SMS_R_System.ResourceId
inner join SMS_G_System_SYSTEM on
SMS_G_System_SYSTEM.ResourceID = SMS_R_System.ResourceId
where
SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName = "Software Installed" and
SMS_G_System_SYSTEM.SystemType = "X64-based PC" and
SMS_R_System.LastLogonUserName not in
(select SMS_R_User.UserName from SMS_R_User where SMS_R_User.UserGroupName = "DOMAIN\\Group")
Whas the article helpful – please rate