How would you create a report to show all groups without roles?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2012 08:30 AM
How would you go about creating a report to show a list of all the groups in the system that don't have at least one role assigned? I'm having problems finding which table to draw this from.
Thank you!
- Labels:
-
Orchestration (ITOM)
-
Service Mapping
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2012 08:50 AM
I'll let someone else tackle the report question, but running this script in Scripts - Background would give you the info:
doit();
function doit() {
var gr = new GlideRecord('sys_user_group');
gr.orderBy("name");
gr.query();
while (gr.next()) {
var role = new GlideRecord("sys_group_has_role");
role.addQuery("group", gr.sys_id);
role.query();
if (!role.hasNext())
gs.print("Group: " + gr.name + " has no roles");
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2012 08:58 AM
CapaJC,
Thank you! That worked perfectly!
I don't really care about making this a report, this was a one-time thing to see which groups didn't have the ITIL role attached to it and it works awesome.
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2022 12:20 PM