- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2024 08:03 AM
Hello,
I have a group called 'test_impersonator'. After doing upgrades, patches, builds, i put multiple members in this group just to allow them to test as other users.
Once all testing is complete, i would like a script that i could run, that would automagically show me all the members of the group, and then delete all those members from the group.
I appreciate the assistance on the way this could be done!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2024 04:05 AM
Hi @northfdl54937
you will also directly remove the users from a group through Background - Scripts
var groupSysId = '0a52d3dcd7011200f2d224837e6103f2';
// Query the Group Members [sys_user_grmember] table to find members of the specified group
var grMember = new GlideRecord('sys_user_grmember');
grMember.addQuery('group', groupSysId);
grMember.query();
while (grMember.next()) {
// Log the user’s Sys ID being removed - for audit purposes
gs.info('Removing user with Sys ID: ' + grMember.user + ' from group: ' + groupSysId);
// Delete the group member record
grMember.deleteRecord();
}
gs.info('All members have been removed from the group with Sys ID: ' + groupSysId);
Note: Note: Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help us a lot.
Thanks & Regards
Deepak Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2024 01:28 AM
Is there any other way instead of deleting records?