Remove users from all itil groups
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2024 12:16 AM
Hii all,
I have to remove some specified users from the all itil groups .Also please note for each user which group they are part of before we remove them from groups, so that in future if needed we can add them back in those groups.
Please tell the approach to achieve this.
Thanks..
1 REPLY 1
Community Alums
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2024 12:32 AM
Hi @Devansh1 ,
I tried your problem in my PDI and I got the solution
Please use below script
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('group', '8a4dde73c6112278017a6a4baf547aa7'); // Group sys_id you can change as per your requirments
gr.query();
gs.print(gr.getRowCount());
while(gr.next()){
gs.print('gr.user = ' + gr.user)
if(gr.user == '22826bf03710200044e0bfc8bcbe5dec'){ // User Sys_id you can change as per your requirments
gs.print('Inside if ');
gr.deleteRecord();
}
}
Result :
When I run the above script
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak