Find groups with only the 'timecard_user' & 'pps_recource' roles
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2024 11:49 PM - edited 09-10-2024 12:17 AM
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
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2024 12:18 AM
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.