Remove all group members

5,182 views
Skip to first unread message

Steve Hall

unread,
Sep 13, 2011, 10:12:21 AM9/13/11
to google-ap...@googlegroups.com
Is there a way to remove all members of a group using GAM? I'm building a solution to re-fresh a series of groups from an external database. Rather than retrieve all the existing members, then send individual commands to remove each of them, then add all the new members, I was hoping I could send a single command to remove all existing members. Is this possible?

Steve

Sreejith Menon

unread,
Sep 13, 2011, 10:17:53 AM9/13/11
to google-ap...@googlegroups.com
The best available option will be, provided your custom solution doesn't conflict is to delete the group and re-create it. Just 2 commands. What do you say?


Regards,
Sreejith Menon

     





On Tue, Sep 13, 2011 at 6:12 PM, Steve Hall <steve...@tyngsboroughps.org> wrote:
Is there a way to remove all members of a group using GAM? I'm building a solution to re-fresh a series of groups from an external database. Rather than retrieve all the existing members, then send individual commands to remove each of them, then add all the new members, I was hoping I could send a single command to remove all existing members. Is this possible?

Steve

--
You received this message because you are subscribed to the "Google Apps Manager" group.
To post to this group, send email to
google-ap...@googlegroups.com
To unsubscribe from this group, send email to
google-apps-man...@googlegroups.com
For more options, visit this group at
https://groups.google.com/forum/#!forum/google-apps-manager

Jay Lee

unread,
Sep 13, 2011, 10:20:01 AM9/13/11
to google-ap...@googlegroups.com
Hi Steve,

  There is no single command to remove all users from a group. I think you'd be best of to:

  1. use "gam info group nnnn" to get a list of all current group members.
  2. have your custom script diff that list against the database and create a list of users to be added and users to be removed.
  3. have GAM add/remove the users as needeed to sync up with the group.
dropping all members from a group and re-adding them would be much slower and problematic for the users themselves.

Jay
--
Jay Lee



On Tue, Sep 13, 2011 at 7:12 AM, Steve Hall <steve...@tyngsboroughps.org> wrote:
Is there a way to remove all members of a group using GAM? I'm building a solution to re-fresh a series of groups from an external database. Rather than retrieve all the existing members, then send individual commands to remove each of them, then add all the new members, I was hoping I could send a single command to remove all existing members. Is this possible?

Steve

--

Jay Lee

unread,
Sep 13, 2011, 10:23:48 AM9/13/11
to google-ap...@googlegroups.com
I'm not sure I'd recommend deleting the group each time either since that would lose ALL of the group's settings and many of those settings can't be set via the API and GAM right now.

Jay
--
Jay Lee

Steve Hall

unread,
Sep 13, 2011, 10:33:31 AM9/13/11
to google-ap...@googlegroups.com
I thought about that. The issue is that the groups have lots of special configurations which cannot be set via GAM (i.e. everything under the "Access", "Email delivery", and "Advanced" tabs). According to the GAM docs...
"...additional groups security settings are available but cannot be set by GAM, this is a Google limitation"

Steve

Steve Hall

unread,
Sep 13, 2011, 10:35:23 AM9/13/11
to google-ap...@googlegroups.com
This is my existing strategy.

Steve

Sreejith Menon

unread,
Sep 13, 2011, 10:45:07 AM9/13/11
to google-ap...@googlegroups.com
Oki. Great.....All the very best ! 


Regards,
Sreejith Menon

     





--

Steve Hall

unread,
Sep 13, 2011, 10:49:43 AM9/13/11
to google-ap...@googlegroups.com
I should have said "This is my existing strategy, but I would still prefer to remove all members in one operation then send the add commands." With the existing strategy, I have to script the retrieval of existing names, parse the results, then do the adds...it's just more work. There are times when I just want to wipe out all the members.

Steve

Moti Levy

unread,
Sep 13, 2011, 11:23:44 AM9/13/11
to google-ap...@googlegroups.com
You can use a simple bash loop: 


for u in `gam info group YOURGROUP | egrep "Member|Owner" | cut -d: -f2` ; do  echo "removing $u" ; gam update group YOURGROUP delete $u  ;done 


Moti 



Jefferson Davis

unread,
Jun 27, 2016, 6:21:51 PM6/27/16
to Google Apps Manager, levy...@gmail.com
OR

for u in `/opt/GAM/gam.py info group <yourgroup> | grep "member: " | sed 's/member: //g' | sed 's/(user)//g'` ; do  /opt/GAM/gam.py update group <yourgroup> remove user $u  ;done 

I may need to take into account owner/manager account status, or remove the parentheses and anything between them.

I suspect some aspects of GAM have been updated since your post.


On Tuesday, September 13, 2011 at 8:23:44 AM UTC-7, Moti Levy wrote:
You can use a simple bash loop: 


for u in `gam info group YOURGROUP | egrep "Member|Owner" | cut -d: -f2` ; do  echo "removing $u" ; gam update group YOURGROUP delete $u  ;done 


Moti 

On Tue, Sep 13, 2011 at 10:49 AM, Steve Hall <steve...@tyngsboroughps.org> wrote:
I should have said "This is my existing strategy, but I would still prefer to remove all members in one operation then send the add commands." With the existing strategy, I have to script the retrieval of existing names, parse the results, then do the adds...it's just more work. There are times when I just want to wipe out all the members.

Steve


On Tue, Sep 13, 2011 at 10:35 AM, Steve Hall <steve...@tyngsboroughps.org> wrote:
This is my existing strategy.

--
You received this message because you are subscribed to the "Google Apps Manager" group.
To post to this group, send email to
google-ap...@googlegroups.com
To unsubscribe from this group, send email to

Ross Scroggs

unread,
Jun 28, 2016, 2:56:20 AM6/28/16
to google-ap...@googlegroups.com
Jefferson,

I've added an option to GAM to allow removing members from groups by role.
gam update groups <Group> clear [owner] [manager] [member]
If you don't specify an option after clear, the members are cleared.

I've submitted a pull request to Jay to include this in his version of GAM,
in the meantime, go here to check it out: https://github.com/taers232c/GAM/releases/tag/v3.66

Ross

You received this message because you are subscribed to the Google Groups "Google Apps Manager" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
To post to this group, send email to google-ap...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/614aa280-b123-41ce-8e12-750fa4b70f14%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Bryan Guidroz

unread,
Jul 15, 2016, 4:23:12 PM7/15/16
to Google Apps Manager
Clearing a group would be great!
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.

Ross Scroggs

unread,
Jul 15, 2016, 5:01:35 PM7/15/16
to google-ap...@googlegroups.com
Bryan,

By "Clearing a group would be great!" do you mean clearing everyone out of the group?
If so, say: gam update group <Group> clear owner manager member
You can specify multiple roles.
(n.b., in my first response I incorrectly said: "gam update groups", it is group singular.)


Ross

OR


For more options, visit this group at
https://groups.google.com/forum/#!forum/google-apps-manager

--
You received this message because you are subscribed to the Google Groups "Google Apps Manager" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Google Apps Manager" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.

To post to this group, send email to google-ap...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.

For more options, visit https://groups.google.com/d/optout.



--

Rahulendra Bhaskar

unread,
Jul 4, 2024, 6:50:20 AM7/4/24
to GAM for Google Workspace
Dear All,

This tested command would be useful for someone-
gam update group <grp name> remove group <grp name>

Ross Scroggs

unread,
Jul 4, 2024, 10:19:44 AM7/4/24
to google-ap...@googlegroups.com
This will remove all the users in <grp name2> (as individual members) from <grp name1>.
gam update group <grp name1> remove group <grp name2> 

If you want to remove <grp name2> as a member from <grp name1> do:
gam update group <grp name1> remove <grp name2> 

Ross
----
Ross Scroggs



You received this message because you are subscribed to the Google Groups "GAM for Google Workspace" group.

To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages