user list not belonging to groups

76 views
Skip to first unread message

Google Workspace ITT Administrator

unread,
Sep 12, 2021, 7:36:04 AM9/12/21
to GAM for Google Workspace
Hello to all. Let me introduce myself: I am Angelo Gigliotti and I have been a Google Workspace administrator since 2014 for my school, a Technical Institute in Viterbo (near Rome). I tried to search through the various discussions but I could not find anything that helped me.
Is it possible to print the list of users who do not belong to any group? I can't find a suitable command. If I write < gam print group-members group "" > I get as response ERROR: 403: Not Authorized to access this resource / api - forbidden
group

Thanks for the help you will be able to give me

Brian Kim

unread,
Sep 12, 2021, 8:01:51 AM9/12/21
to GAM for Google Workspace

This should help. do you have a group that's named group? or is that just an example? gam print group-members will show all groups, if you specify a group after the command, it will look for that specific group, which may not exist. Otherwise, try doing gam oauth update and make sure that your admin account has ability to read groups and the members.

Google Workspace ITT Administrator

unread,
Sep 12, 2021, 1:23:33 PM9/12/21
to GAM for Google Workspace
Thanks. Now I try with your script...

Chris River

unread,
Sep 13, 2021, 10:12:55 AM9/13/21
to GAM for Google Workspace
If you're using GAMADV-XTD3, you can run this command: gam config auto_batch_min 1 redirect csv - multiprocess all users print groups countsonly

Replace "csv -" with "csv ./usergroupcounts.csv" or your preferred file name to print the output to a file. This command will generate output that looks like this, showing the number of groups that each user is a member, manager, or owner of:
User,MEMBER,MANAGER,OWNER
user1@domain,0,0,0
user2@domain,1,0,0
user3@domain,1,0,0
user4@domain,15,0,2

This might not be as efficient as the python script that Brian posted, but it will likely work quickly enough. If you want GAM to only list users that are not members of any group, then you can have GAM filter the output for you:
gam config auto_batch_min 1 csv_output_row_filter "MEMBER:count=0,MANAGER:count=0,OWNER:count=0" redirect csv - multiprocess all users print groups countsonly
Reply all
Reply to author
Forward
0 new messages