Deleting Suspended Users From Groups

3,897 views
Skip to first unread message

Eric Dannewitz

unread,
Sep 14, 2017, 3:17:19 PM9/14/17
to google-ap...@googlegroups.com
I’m looking for an easy way to remove user accounts that have been suspended from groups. Would I have to create a CSV of users that are suspended do something like this with member being the first record in the csv

gam redirect stdout ./removefromgroups.log multiprocess redirect stderr stout csv suspendedusers.csv gam update groups llhsacadstaff remove ~member




---
Eric Dannewitz 
Technology Assistant
Acalanes Union High School District
District Office Technology Department

Andy Poirier

unread,
Sep 14, 2017, 3:44:57 PM9/14/17
to google-ap...@googlegroups.com

Andy Poirier

Sr. IT Engineer


W E D D I N G W I R E


301 231 9473

an...@weddingwire.com

websitefacebookinstagramlinkedin



--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.
To post to this group, send email to google-apps-manager@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/2B013E27-360F-494D-B2C3-7135EAE57CDD%40auhsdschools.org.
For more options, visit https://groups.google.com/d/optout.

Ross Scroggs

unread,
Sep 14, 2017, 3:57:23 PM9/14/17
to google-ap...@googlegroups.com
Eric,

With advanced Gam (https://github.com/taers232c/GAMADV-X) you can do what you want in a single command.

gam update group|groups <GroupEntity> clear [member] [manager] [owner] [suspended]


Ross

On Thu, Sep 14, 2017 at 12:44 PM, 'Andy Poirier' via GAM for G Suite <google-ap...@googlegroups.com> wrote:

Andy Poirier

Sr. IT Engineer


W E D D I N G W I R E


301 231 9473

an...@weddingwire.com

websitefacebookinstagramlinkedin


On Thu, Sep 14, 2017 at 3:17 PM, Eric Dannewitz <edann...@auhsdschools.org> wrote:
I’m looking for an easy way to remove user accounts that have been suspended from groups. Would I have to create a CSV of users that are suspended do something like this with member being the first record in the csv

gam redirect stdout ./removefromgroups.log multiprocess redirect stderr stout csv suspendedusers.csv gam update groups llhsacadstaff remove ~member




---
Eric Dannewitz 
Technology Assistant
Acalanes Union High School District
District Office Technology Department

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsubscribe...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.
To post to this group, send email to google-apps-manager@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.

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



--

Eric Dannewitz

unread,
Sep 14, 2017, 3:58:39 PM9/14/17
to google-ap...@googlegroups.com
Oh my, I think you deserve some Diet Coke for that. Or pizza.

And here I was going to write a python script to do it....

Sent from my iPad
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.

Eric Dannewitz

unread,
Sep 14, 2017, 4:04:05 PM9/14/17
to google-ap...@googlegroups.com
Though, if you wanted to go through ALL the groups in your organization, you would still have to create a csv of the groups, and then do something like this

Gam redirect stdout removedfromgroup.log multiprocess redirect stderr stout csv all groups.csv gam update group ~group clear suspended

Right?

---
Eric Dannewitz 
Technology Assistant
Acalanes Union High School District
District Office Technology Department
On Sep 14, 2017, at 12:57 PM, Ross Scroggs <ross.s...@gmail.com> wrote:

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.

Ross Scroggs

unread,
Sep 14, 2017, 4:10:26 PM9/14/17
to google-ap...@googlegroups.com
Eric,

Right, to do all groups you have to get the list of groups.

gam print groups | gam redirect stdout removedfromgroup.log multiprocess redirect stderr stdout csv - gam update group ~Email clear suspended

Ross

On Thu, Sep 14, 2017 at 1:03 PM, Eric Dannewitz <edann...@auhsdschools.org> wrote:
Though, if you wanted to go through ALL the groups in your organization, you would still have to create a csv of the groups, and then do something like this

Gam redirect stdout removedfromgroup.log multiprocess redirect stderr stout csv all groups.csv gam update group ~group clear suspended

Right?

---
Eric Dannewitz 
Technology Assistant
Acalanes Union High School District
District Office Technology Department
On Sep 14, 2017, at 12:57 PM, Ross Scroggs <ross.s...@gmail.com> wrote:

Eric,

With advanced Gam (https://github.com/taers232c/GAMADV-X) you can do what you want in a single command.

gam update group|groups <GroupEntity> clear [member] [manager] [owner] [suspended]

Ross



--

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.
To post to this group, send email to google-apps-manager@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.
To post to this group, send email to google-apps-manager@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.

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



--

fakir dounia

unread,
May 24, 2018, 6:51:23 PM5/24/18
to GAM for G Suite
hi ross , i tried to use the same command to clear the bouncing members but its not working . the command was like this:  gam update group|groups <GroupEntity> clear member bouncing .   is there any command to clear all the  members who have the  Delivery status (bouncing). ?   Thanks :)
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.
To post to this group, send email to google-ap...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.
To post to this group, send email to google-ap...@googlegroups.com.



--

James Haron

unread,
Oct 10, 2018, 2:53:56 PM10/10/18
to GAM for G Suite
Fakir > you have reslove this problem or no ?

Ross Scroggs

unread,
Oct 10, 2018, 3:25:45 PM10/10/18
to google-ap...@googlegroups.com
James/Fakir,

There is no API support for what you are asking; thus Gam can't help directly.
In the Admin console, you could export the bouncing members and then use Gam to delete the members.

Ross

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 "GAM for G Suite" 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.



--

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" 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.


--

M F

unread,
Mar 17, 2023, 12:55:58 AM3/17/23
to GAM for Google Workspace
As is noted in this thread, this command:

Gam redirect stdout removedfromgroup.log multiprocess redirect stderr stout csv all groups.csv gam update group ~group clear suspended

...won't work unless you're on Advanced GAM but I can't seem to get the log file to create. Is it supposed to create it in the same directory as the command is executed? I'm running it from MacOS if that makes any difference on zsh shell.

M F

unread,
Mar 17, 2023, 12:55:58 AM3/17/23
to GAM for Google Workspace
In case anyone else is struggling... I hope this helps. 😊

Once I removed stderr from the command, it posted the error to terminal so I could see it. The following command:

gam print groups | gam redirect stdout removedfromgroup.log multiprocess redirect stdout csv - gam update group "~email" clear suspended 

...gives me the following output:

ERROR: Invalid choice (-): Expected <all|cigroup|cigroup_users|cigroups|courseparticipants|cros|cros_ou|cros_ou_and_children|cros_ou_and_children_queries|cros_ou_and_children_query|cros_ou_queries|cros_ou_query|cros_ous|cros_ous_and_children|cros_ous_and_children_queries|cros_ous_and_children_query|cros_ous_queries|cros_ous_query|cros_sn|croscsv|croscsv_sn|croscsvdata|croscsvfile|croscsvfile_sn|crosfile|crosfile_sn|crosqueries|crosquery|csv|csvdata|csvdatafile|csvfile|csvkmd|csvsubkey|datafile|domains|domains_ns|domains_susp|file|group|group_inde|group_ns|group_susp|group_users|group_users_ns|group_users_select|group_users_susp|groups|groups_inde|groups_ns|groups_susp|licenses|oauthuser|ou|ou_and_children|ou_and_children_ns|ou_and_children_susp|ou_ns|ou_susp|ous|ous_and_children|ous_and_children_ns|ous_and_children_susp|ous_ns|ous_susp|queries|query|students|teachers|user|users>
Help: Syntax in file /Users/<username>/bin/gamadv-xtd3/GamCommands.txt
Help: Documentation is at https://github.com/taers232c/GAMADV-XTD3/wiki
Getting all Groups, may take some time on a large Google Workspace Account...
Got ## Groups: <email address> - <email address>
Traceback (most recent call last):
  File "__main__.py", line 40, in <module>
  File "__main__.py", line 28, in main
  File "__init__.py", line 67985, in ProcessGAMCommand
  File "__init__.py", line 67866, in closeSTDFilesIfNotMultiprocessing
  File "__init__.py", line 67862, in closeSTDFile
BrokenPipeError: [Errno 32] Broken pipe
[24751] Failed to execute script '__main__' due to unhandled exception!

The funny thing is if I remove the redirect section and run the following: 

gam print groups | gam csv - gam update group "~email" clear suspended

...it works perfectly. 

If I run the following: 

gam print groups | gam csv - gam update group "~email" clear suspended > removedfromgroup.log (or removedfromgroup.csv) 

...it works perfect. I'm guessing the point of the redirect/multiprocess is to get the log written simultaneously so its faster? But that syntax must have updated since your post in 2017.

If you have a way to do multiprocess still, it's a great idea but I have a well-enough-baked solution so I'm not going to dig through /Users/<username>/bin/gamadv-xtd3/GamCommands.txt to find the solution. 😊
On Wednesday, October 10, 2018 at 1:25:45 PM UTC-6 Ross Scroggs wrote:

Ross Scroggs

unread,
Mar 17, 2023, 8:14:53 AM3/17/23
to google-ap...@googlegroups.com
See: https://github.com/taers232c/GAMADV-XTD3/wiki/Meta-Commands-and-File-Redirection#file-redirection

Since you just specified a filename, it's in the directory specified by drive_dir in gam.cfg, the default value is you downloads folder.

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.

EDWARD ARAGON

unread,
Aug 19, 2023, 9:46:39 AM8/19/23
to GAM for Google Workspace
Also once you know a user is no longer with your organization. Sharing info I saw from another thread. The command will remove all the previous employee's group memberships. Hope this helps.
Gam user < email> delete groups

Bob Walton

unread,
Jul 24, 2024, 4:23:48 PM7/24/24
to GAM for Google Workspace

Seven years later, but at least now there is an easy way to do this...


Run:

gam print groups >groups.csv

Then run:

gam csv groups.csv gam update group "~email" clear suspended  

Reply all
Reply to author
Forward
0 new messages