GAM - Update-Delete for single command

988 views
Skip to first unread message

yoomes

unread,
May 25, 2018, 2:26:12 AM5/25/18
to GAM for G Suite
Hi. I have been trying to run or test a single command below to unsuspend account and to reset a password thru cmd

gam.exe update user <email address> suspended off

and 

gam  update user <email address> password <Password>

results: updating user <email address>....

I don't know why it takes so long to update since it is a single command. I have installed this as my 3rd part app to bulk delete-update google accounts.


Please advise. Thank you:)


+KimNilsson

unread,
May 25, 2018, 7:31:21 AM5/25/18
to GAM for G Suite
How many times have you tried?
It should take no time at all.

But, I just noticed that my cli in MacOS didn't like setting a manual password with !. It just gave me weird errors.

Cathlyn Angeles

unread,
May 28, 2018, 7:29:31 AM5/28/18
to GAM for G Suite
Hi. As per trying today, it's working fine now on the single command. and now testing on bulk update operation.

I am now trying to test mass movement of user to other OU with this command:
gam csv updateou.csv update org testdummy/testGr10 add users "~Email Address" (I also tried to specify the full path C:\GAM\updateou.csv but still getting the same error)

Result: Error: no such file or directory.

But I make sure that my csv file lives in GAM folder.

by the way i am running in cmd-windows, GAM version 

Noong Biyernes, Mayo 25, 2018 ng 7:31:21 PM UTC+8, si +KimNilsson ay sumulat:

+KimNilsson

unread,
May 30, 2018, 4:00:43 AM5/30/18
to GAM for G Suite
Yes, unless you have GAM in your path you need to either have the files inside the GAM folder or give the full path to csv files.
But, your syntax is wrong. You need to have one more gam command. One to read the csv file and one to do the actual command.

gam csv updateou.csv gam update user ~"Email Address" org "testdummy/testGr10"

In fact, I'd recommend you change the header in your csv file for the users' email addresses to a single word.

gam csv updateou.csv gam update user ~Email org "testdummy/testGr10"

Also, if you have a second column in your csv called OU with each user's OU, you could move each user to a different place.

gam csv updateou.csv gam update user ~Email org ~OU

geewonie

unread,
Jun 1, 2018, 12:11:27 AM6/1/18
to GAM for G Suite
Thank you so much for your kind reply, Kim!

I was able to run successfully the syntax below:
gam csv updateou.csv gam update org TestDummy/TestGr10 add user "~Email Address".

Yes, I will make the header in my csv for the users' email addresses as a single word = email.

I will now try to test moving each users to a different OU. I'll update my csv file first to include OU. 

May I know please if the command is also the same for updating/moving of users to other groups? Just change the parameter.

Thanks so much.

Kim Nilsson

unread,
Jun 1, 2018, 3:53:13 AM6/1/18
to Google Apps Manager
Pretty much the same.

gam csv updategroups.csv gam update group test...@domain.name add member ~Email

and with different groups for different users

gam csv updategroups.csv gam update group ~Group add member ~Email

or you instead sync users in your OUs to different groups - that will also take care of removing users no longer in the OU.

gam csv updategroups.csv gam update group ~Group sync member notsuspended ou ~OU


/Kim
--
There is No Substitute!

geewonie

unread,
Jun 1, 2018, 4:08:50 AM6/1/18
to GAM for G Suite
Tried running:

gam csv ou2.csv gam update  user  ~Email org ~OU 

but got error 400: Invalid Input : INVALID_OU_ID - Invalid

I have updated my csv file to use for this one.

What is invalid here? Thanks..

geewonie

unread,
Jun 1, 2018, 4:22:34 AM6/1/18
to GAM for G Suite
For Mass update/change of Group command, is there a syntax for mass update of user groups (removing from one group and adding to another)? 

There are still users that has the same place of OU but have different groups. How to do this one? 

+KimNilsson

unread,
Jun 1, 2018, 4:45:55 AM6/1/18
to GAM for G Suite
The OU has to already exist in your domain.
GAM doesn't also create the OU.

Sometimes the reference to OU should be with a leading / and if you have OUs with spaces you need to change the syntax a little bit.

gam csv ou2.csv gam update  user  ~Email org ~~OU~~

alternatively

gam csv ou2.csv gam update  user  ~Email org ~"OU"

I don't think you need to combine the use of double ~~and "". But try and let me know.

geewonie

unread,
Jun 1, 2018, 5:02:35 AM6/1/18
to GAM for G Suite
Still got the same error. 

Is it on my csv file? 

Last Name-First Name-Email-OU
sample - test - sampl...@domain.name.com- TestGr10 
dummy - test - sampl...@domain.name.com- Test Gr08

+KimNilsson

unread,
Jun 1, 2018, 5:08:58 AM6/1/18
to GAM for G Suite
No, you'd need two commands for that.
Also, you'd need two separate values in your csv.
One for which groups to add, and one for which groups to remove.

Then run the command twice. Once with add member and once with delete member.

Using sync you can only manipulate one group at the time (afaik). I've never tried

+KimNilsson

unread,
Jun 1, 2018, 5:11:14 AM6/1/18
to GAM for G Suite
I'm assuming you really have everything separated by , and not -.

The OUs need to exist in G Suite, and they have to exactly the same.

I see you have a space in the second OU.

Andrew Penner

unread,
Jun 1, 2018, 10:45:32 AM6/1/18
to google-ap...@googlegroups.com
You could also use a csv file with the following headers: group,action,usertype,email

Your entries would look something like:

This method works great for dozens or hundreds of updates; in my experience, each update takes about 3 seconds to process, so I run the powershell script and do something else while it's running.

For larger numbers, I'm starting to experiment with batch files; instead of a csv file with your variables, each line of the batch file is a separate command updating one user/group:
gam update group gro...@domain.org add member mem...@domain.org
gam update group gro...@domain.org add manager mem...@domain.org
gam update group gro...@domain.org delete owner mem...@domain.org

In my initial testing, the batch file process seems faster by at least a couple of orders of magnitude.

______________________________________________________
Andrew Penner, Technical Analyst III (A+, MCP, MCDST)
Office: 780-460-3712 (333)
Mobile:780-913-7576
60 Sir Winston Churchill Ave
St. Albert, AB T8N 0G4




--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/3ab37da6-5e34-46eb-a400-4ca8e939702c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



  Find us on Facebook:
  Follow us on Twitter: 

geewonie

unread,
Jun 3, 2018, 8:57:56 PM6/3/18
to GAM for G Suite
Ooops, sorry for the confusion. no, i'm not using -.

yes, OUs were already existed in G Suite and are exactly the same. I have OUs that has spaces, and has - (like MT - SHS)


So for this, I am trying to test it before my actual mass update of OU.

Just for testing, OUs are:

TestGr10
Test Gr08
MT - SHS

Ross Scroggs

unread,
Jun 3, 2018, 10:55:23 PM6/3/18
to google-ap...@googlegroups.com
geewonie,

I'm having trouble following: please post an accurate sample CSV file (i.e., doun't show - if you are actually using ,), the Gam command you're tryinh to excute and the output from that command.

From that we should be able to get you going.

--
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.

geewonie

unread,
Jun 3, 2018, 11:24:45 PM6/3/18
to GAM for G Suite
Hi, Ross.

my csv file contains the following header: Last Name, First Name, Email, OU

sample data:

Last Name, First Name, name@domain, TestGr10
Last Name, First Name, name@domain, Test Gr08


so i'm running this command:

C:\GAM> gam csv differentou.csv gam update ~Email org ~"OU"

Got error below:
ERROR: 400: Invallide Input: INVALID_OU_ID - invalid


I tested on bulk update/movement of accounts to other OU before but with in the same place (and it works fine) so I'm testing in one csv file if it'll works on different OUs.

Thanks.. :)

On Monday, June 4, 2018 at 10:55:23 AM UTC+8, Ross Scroggs wrote:
geewonie,

I'm having trouble following: please post an accurate sample CSV file (i.e., doun't show - if you are actually using ,), the Gam command you're tryinh to excute and the output from that command.

From that we should be able to get you going.

On Jun 3, 2018, at 5:57 PM, geewonie <cathlyn...@apecschools.edu.ph> wrote:

Ooops, sorry for the confusion. no, i'm not using -.

yes, OUs were already existed in G Suite and are exactly the same. I have OUs that has spaces, and has - (like MT - SHS)


So for this, I am trying to test it before my actual mass update of OU.

Just for testing, OUs are:

TestGr10
Test Gr08
MT - SHS



On Friday, June 1, 2018 at 5:11:14 PM UTC+8, +KimNilsson wrote:
I'm assuming you really have everything separated by , and not -.

The OUs need to exist in G Suite, and they have to exactly the same.

I see you have a space in the second OU.

--
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.

Ross Scroggs

unread,
Jun 3, 2018, 11:49:25 PM6/3/18
to google-ap...@googlegroups.com
This is incorrect:
my csv file contains the following header: Last Name, First Name, Email, OU
It should be:
my csv file contains the following header: Last Name,First Name,Email,OU

This is incorrect:
Last Name, First Name, name@domain, TestGr10
Last Name, First Name, name@domain, Test Gr08
It should be:
Last Name,First Name,name@domain,TestGr10
Last Name,First Name,name@domain,Test Gr08

There should be no spaces after the commas.

This command is not valid as it's missing the option user which is what you're trying to update. The quotes around OU are unnecessary
C:\GAM> gam csv differentou.csv gam update ~Email org ~"OU"
It should be :
C:\GAM> gam csv differentou.csv gam update user ~Email org ~OU

Ross

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.

geewonie

unread,
Jun 4, 2018, 12:09:25 AM6/4/18
to GAM for G Suite
Ooops, sorry for the confusion. That was only for reply here.

my csv filtetype is Microsoft Excel Comma Separated Values. I saved it as type CSV (Comma Delimited). Please note that I have successfully tested mass update (only with the same OU)) last week using the same kind of file type.



Ross Scroggs

unread,
Jun 4, 2018, 12:20:38 AM6/4/18
to google-ap...@googlegroups.com
I need accurate data, do not reformat it; I can duplicate your problem if there are leading/trailing spaces around the OU data in the rows.

For instance, this command:
C:\GAM> gam csv differentou.csv gam update ~Email org ~"OU"
gives this error:
ERROR: us...@domain.com is not a valid argument for "gam update"
not this error:
ERROR: 400: Invallide Input: INVALID_OU_ID - invalid

If you'd like, send me privately your sample data file.

Ross

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.

Ross Scroggs

unread,
Jun 4, 2018, 1:05:26 AM6/4/18
to google-ap...@googlegroups.com
If you have an Excel spreadsheet with leading spaces in a column, they will be preserved when being written to a CSV file.

differentou.csv
Last Name,First Name,Email,OU
last,first,us...@domain.com, TestGr10
last,first,us...@domain.com, Test Gr08

This will fail with an invalid OU error bacause of the leading space in front of the OU names; check your CSV file.
gam csv differentou.csv gam update user ~Email ou ~OU

Ross
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.

geewonie

unread,
Jun 4, 2018, 1:10:44 AM6/4/18
to GAM for G Suite
Yes, there's spaces in OU  - test Gr08

Most of my actual OU in G Suite has spaces and -.

I almost input here the actual csv file. My data in the rows are the following format:

Header: Last Name,First Name,Email,OU

Data:
Last Name,First Name,user@domain,TestGr10
Last Name,First Name,user@domain,Test Gr08


geewonie

unread,
Jun 4, 2018, 4:28:24 AM6/4/18
to GAM for G Suite
To add:
 
- Users to be moved from one OU to other OU should only be added in the list of users in the OU parameter.

- To take note that those samples of OU (TestGr10 and Test Gr08) are Sub-OU. Parent OU is TestOU. 

These are only test data. Actual OU would be like there's spaces, and -.

Tried testing and rechecking my csv file and OUs in G Suite and it seems right but I don't know why I keep getting the error results.

Please advise and thank you so much for being so patient on this matter.

✉ Kevin Melillo

unread,
Jun 4, 2018, 8:37:43 AM6/4/18
to google-ap...@googlegroups.com
Not exactly sure about your use case here, but let's travel down the rabbit hole.  The Header Row should not include spaces.

Header Row:
LastName,FirstName,Email,OU

When GAM sees ~Email it knows to substitute the value...  but when GAM sees ~Last Name, it does not see the header ~Last and it does not know how the Name is supposed to resolve.  The space in there is what may be interfering. 

Also...  not sure if you really need FirstName and LastName for what you are doing here.  Is there a reason you are including them in the CSV file?

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.

--
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.

--
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.


--
Kevin Melillo
Electronic Communications Analyst
Information Technology
445 Hoes Lane
Piscataway, NJ 08854

Phone:732-465-6609 | Mobile: 732-609-4331

Ross Scroggs

unread,
Jun 4, 2018, 8:51:33 AM6/4/18
to google-ap...@googlegroups.com
Once again, I need to see accurate data; this is the first you've mentioned Sub-OUs.
If you're trying to move a user to a Sub-OU of TestOU, then the rows in the CSV file should look like this:
Last Name,First Name,user@domain,TestOU/TestGr10
Last Name,First Name,user@domain,TestOU/Test Gr08

Ross
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.

geewonie

unread,
Jun 4, 2018, 9:01:35 PM6/4/18
to GAM for G Suite
Hi, Ross.

Updated the rows in my CSV file and exactly look the format you have sent and run the same command.

got this error:
ERROR: user@domain is not a valid argument for "gam update"

I don't know why it become invalid since those are the accounts are active and I have been using those for testing.

Ross Scroggs

unread,
Jun 4, 2018, 9:22:26 PM6/4/18
to google-ap...@googlegroups.com
You're leaving out a keyword; note the keyword user after the word update.
This is incorrect:
C:\GAM> gam csv differentou.csv gam update ~Email org ~"OU"
It should be:
C:\GAM> gam csv differentou.csv gam update user ~Email org ~OU

Ross

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.

geewonie

unread,
Jun 4, 2018, 9:57:48 PM6/4/18
to GAM for G Suite
Finally! It works!! Thank you so much for your kindness and patience with me, Ross! 

Already tried testing it thrice to see if it works fine. You need to fully check all the OUs, the row data format and the gam commands being. Truly a great experience to learn how it works on my end. I'll take note on this. I am now on my testing on the groups update. gam command I'll be using is gam csv updategroups.csv gam update group ~Group add member ~Email so my excel csv will contains at least group's email addresses and users' email addresses. 


but I'm looking for a gam command to print all users in groups. I have already printed all users with OU


Thank you once again, Ross. You are such a big help. Continue to be a blessing. God bless you always. 

Ross Scroggs

unread,
Jun 4, 2018, 11:34:43 PM6/4/18
to google-ap...@googlegroups.com
but I'm looking for a gam command to print all users in groups. I have already printed all users with OU

There are two ways to get this data depending on the format of the output that is useful to you.
gam print groups delimiter " " name members > GroupMembers.csv
You get one row per group with the headers:
Email,Name,MembersCount,Members
Email - group email address
Name - group name
MembersCount - number of members
Members - " " delimited list of member email addresses (specify a different delimiter if you'd like)
You can add the options owners and/or managers to get the columns:
ManagersCount,Managers,OwnersCount,Owners

gam print group-members roles members > GroupMembers.csv
You get one row per member per group with the headers:
group,status,email,role,type,id
group - group email address
status - status of member in group: ACTIVE or SUSPENDED
email - member's email address
role - member's role: OWNER, MANAGER, MEMBER
type - member's type: USER, GROUP, CUSTOMER
id - User, group or customer ID
You can say roles members,manager,owners if you want the additional roles


Ross

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.

Chris Avila

unread,
Jun 8, 2018, 1:14:23 PM6/8/18
to GAM for G Suite
Ross,

I've read through this thread, as well as a number of others, and I seem to be having an issue with GAM and the CSV command actually seeing the file. my CSV file resides in my gam folder and I'm running the latest version of GAM on macOS with the following command:

gam csv deletestu.csv gam delete user ~User


I get the following output in Terminal:


ERROR: [Errno 2] No such file or directory: 'deletestu.csv'


I've also entered the full path, HardDrive/Users/Me/Bin/gam/deletestu.csv, with the same result. Any suggestions?

Kim Nilsson

unread,
Jun 8, 2018, 3:07:52 PM6/8/18
to Google Apps Manager
Try this,

gam csv ./deletestu.csv gam delete user ~User
Reply all
Reply to author
Forward
0 new messages