Find groups with only the 'timecard_user' & 'pps_recource' roles

Brian15
Tera Guru

I need help with a script that returns all groups containing only two roles.  The two roles are 'timecard_user' & 'pps_recource'.  

 

Next, the two roles should be removed from all other active groups.

 

Thanks!

Brian

1 REPLY 1

Harsh_Deep
Giga Sage
Giga Sage

Hello @Brian15 

 

Please use below script-

var groups=[];
var getGroup = new GlideRecord('sys_group_has_role');
getGroup.addEncodedQuery('role.name=pps_recource^ORrole.name=timecard_user');
getGroup.query();
while(getGroup.next()){
    groups.push(getGroup.group.name);
}
gs.info(groups);

 

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.