Trying to use GAM to bulk suspend users.

6,550 views
Skip to first unread message

R2Carney

unread,
Oct 16, 2013, 8:04:26 AM10/16/13
to google-ap...@googlegroups.com
Hi,

I am trying to use GAM in a powershell script to bulk suspend a list of users. 

The script I am using is this..

$list = Import-Csv C:\gam\suspend.csv
foreach ($entry in $list)
 { 

 c:\gam\gam.exe update user $($entry.username) suspended on

 }


I am getting an error that says the following:

Error: didn't expect on command at position 4
{}
Dito GAM 3.02
Python 2.7.5 64-bit final
google-api-python-client 1.2
Windows-7-6.1.7601-SP1 AMD64
Path: C:\gam\


Has anyone seen that or know what might be causing it? 

Thanks, 
Robin

Jay Lee

unread,
Oct 16, 2013, 8:27:03 AM10/16/13
to google-ap...@googlegroups.com
Powershell can be a pain in the neck sometimes. GAM 3.1 can process the CSV much easier and MUCH faster:

gam csv C:\gam\suspend.csv gam update user $email suspended on

just make sure suspend.csv has a header line of "email" and you should be good to go.



Regards,

Jay Lee
Director of Google Apps Deployments   |  Dito


--
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 http://groups.google.com/group/google-apps-manager.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/1eee5059-dec2-4578-81e4-c35dc89d58de%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

R2Carney

unread,
Oct 16, 2013, 9:46:29 AM10/16/13
to google-ap...@googlegroups.com
Thanks Jay!
 
That worked great on most of the users. I initially had a list of 369 users and this worked on all but 84 of them. The error i'm getting on the ones it didn't work for is:
 
<HttpError 403 when requesting https://www.googleapis.com/admin/directory/v1/use
rs/user...@warriors.winnacunnet.org?quotaUser=4ba52ec083cfc90e1625a6e092eb
54a44749fa04&fields=primaryEmail&alt=json&prettyPrint=false returned "Requestrat
e Exceeded">
 
Any idea what would cause that?
 
Thanks for your help,
-Robin
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.

Bruce Selzler

unread,
Jun 6, 2014, 10:56:00 AM6/6/14
to google-ap...@googlegroups.com, j...@ditoweb.com
Hello Team,

Does the CSV file contain a list of email address' or usernames? 

- Sez
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.

Andrew Rowland

unread,
Jul 14, 2014, 1:28:55 PM7/14/14
to google-ap...@googlegroups.com, j...@ditoweb.com
I'm getting the error: Error 404 resource not found: userKey - not found

Any ideas?

Jay Lee

unread,
Jul 14, 2014, 1:48:33 PM7/14/14
to google-ap...@googlegroups.com
Andrew,

  Can you offer a little more context here? Are you trying to suspend a bunch of users or something else?

  Have you confirmed the user exists and you have the address exactly right?


Jay Lee


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 http://groups.google.com/group/google-apps-manager.

Garren McKelvey

unread,
May 28, 2015, 3:37:15 PM5/28/15
to google-ap...@googlegroups.com
hello.  I'm having a similar issue.  I'm trying to suspend users in bulk.  I used the command below:

gam csv C:\gam\suspend.csv gam update user ~email suspended on

But I keep getting this error:

c:\gam-64>gam csv C:\gam\suspend.csv gam update user ~email suspended on
Traceback (most recent call last):
  File "<string>", line 7346, in <module>
IOError: [Errno 2] No such file or directory: u'C:\\gam\\suspend.csv'

The error is clear.  For some reason the command is trying to put two \ marks where there should only be one.  However I can't see any way to fix this.  Help?

Brian Gray

unread,
May 29, 2015, 3:11:35 PM5/29/15
to google-ap...@googlegroups.com


On Thursday, May 28, 2015 at 2:37:15 PM UTC-5, Garren McKelvey wrote:
gam csv C:\gam\suspend.csv gam update user ~email suspended on


You can try these 2 ideas:
1) move the CSV file to the same folder as the gam executable, and leave out any path references:  gam csv suspend.csv gam update user ~email suspended on
2) use forward slash instead of backslash: gam csv C:/gam/suspend.csv gam update user ~email suspended on

Shane Schaetz

unread,
Mar 19, 2015, 12:56:16 PM3/19/15
to google-ap...@googlegroups.com
For posterity, the command should have been gam csv C:\gam\suspend.csv gam update user ~email suspended on

Notice the ~ instead of the $.


Jay Lee


Any ideas?
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 "Google Apps Manager" 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.
Visit this group at http://groups.google.com/group/google-apps-manager.

Scott Matarazzo

unread,
Mar 30, 2016, 3:55:04 PM3/30/16
to Google Apps Manager
I run "gam csv suspend.csv gam update user ~email suspended on" and get "error 403 not authorized to access this resource/api - forbidden"

it suspends the first account listed in the csv but not the rest and ends with that error.


Can someone help? I need to do a bulk suspend on Tuesday April 5,2016

Nate Ferrell

unread,
Apr 1, 2016, 12:39:06 PM4/1/16
to Google Apps Manager
Sounds like you need to double check the admin permissions for the user running the command... wouldn't hurt to reauthorize GAM too as a checkpoint

if any of the users you're suspending are admins, then you *may* need to have SuperAdmin privileges to suspend them

Scott Matarazzo

unread,
Apr 1, 2016, 12:52:34 PM4/1/16
to Google Apps Manager
Nate thanks for the response. After I tried reauthorizing and running the command I realized what the issue was. It was user error on my part, I had a typo in the email account. This has resolved my issue.



Thanks again!

Nate Ferrell

unread,
Apr 1, 2016, 12:59:59 PM4/1/16
to google-ap...@googlegroups.com
Awesome!! 😁

Thank you for your time,
Nate Ferrell
Systems Engineer | Google Apps Certified Administrator
x5120 | 817.494.0332


--
You received this message because you are subscribed to a topic in the Google Groups "Google Apps Manager" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-apps-manager/R64nHwDlXww/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-apps-man...@googlegroups.com.

To post to this group, send email to google-ap...@googlegroups.com.

Manuel Pedro Barros

unread,
Sep 10, 2016, 8:49:45 AM9/10/16
to Google Apps Manager
Thanks for the ~tip Shane!
Reply all
Reply to author
Forward
0 new messages