Report on the users with no roles and groups
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-22-2025 09:50 AM
I need to pull a report of users with no roles and no groups.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-22-2025 10:40 AM
Hi @VojjalaS,
Here's a background script that I run from time to time to pull exactly this information.
var usersWithoutRolesOrGroups = [];
var userGR = new GlideRecord('sys_user');
userGR.addActiveQuery(); // Checking active users only.
userGR.query();
while (userGR.next()) {
// Check for roles associated to the user
var roleGR = new GlideRecord('sys_user_has_role');
roleGR.addQuery('user', userGR.sys_id);
roleGR.query();
// Check to see if user associated to any groups
var groupGR = new GlideRecord('sys_user_grmember');
groupGR.addQuery('user', userGR.sys_id);
groupGR.query();
if (!roleGR.hasNext() && !groupGR.hasNext()) {
// Push relevant user data to the array
usersWithoutRolesOrGroups.push({
name: userGR.getValue('name'),
username: userGR.getValue('user_name'),
email: userGR.getValue('email'),
sys_id: userGR.getValue('sys_id')
});
}
}
// Results (This could be adapted if you want to separate out role and/or group membership)
gs.print('Users with no roles and not a member of any groups: ' + usersWithoutRolesOrGroups.length);
gs.print(JSON.stringify(usersWithoutRolesOrGroups, null, 2));
To help others (and for me to gain recognition for my efforts), please mark this response correct by clicking on Accept as Solution and/or Kudos.

Thanks, Robbie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-23-2025 01:37 AM
Dear @VojjalaS
Good day ! Hope you are doing great ..
You may try the below method to get the list of active users who dont have role. Explore and see if this fulfills your needs.
You can enter this " javascript:getRoledUsers()" under sysid
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-23-2025 11:45 PM
Dear @VojjalaS Would like to know if you achieved what you looking for .. Have a great day !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-24-2025 06:53 AM
Yes. Thank you Sudhakar.