Batch commands on GAMADV-XTD

1,893 views
Skip to first unread message

Paul Horton

unread,
May 3, 2018, 8:00:22 AM5/3/18
to GAM for G Suite
Hi all, 

I'm trying to batch some commands which allow removal of link shares from a leaver's files, and then transfers those files to an archive user, then deletes the user. 

However, I want to be able to automate it for use with multiple users. Is there any way in a Batch file to request a user input from the terminal?

Using Gamadv-xtd on Mac 

Thanks very much!

Paul

✉ Kevin Melillo

unread,
May 3, 2018, 8:08:28 AM5/3/18
to google-ap...@googlegroups.com
Are you using PowerShell?  Bash?  Other?

--
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/3698c0a4-5779-493c-82b6-33714688ec99%40googlegroups.com.
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,
May 3, 2018, 8:31:44 AM5/3/18
to google-ap...@googlegroups.com
Paul,

If you mean can the following accept user input, the answer is no: gam batch file.bat
If you mean can a bash script accept user input the answer is yes.

Give me an example of what you're trying to do.

Ross Scroggs

unread,
May 3, 2018, 9:31:16 AM5/3/18
to google-ap...@googlegroups.com
Paul,

Generate the list of users by prompting, then write a file Users.txt with those email addresses, there is no header row.

Make a gam batch file Users.bat that looks like this:
gam file Users.txt <put first gam command arguments here>
commit-batch
gam file Users.txt <put second gam command arguments here>
commit-batch
gam file Users.txt <put third gam command arguments here>
commit-batch

The commit-batch lines make sure that each command finishes before the next one starts; if two commands can run in parallel, omit the commit-batch.

Execute the batch:
gam batch Users.bat

This is a serial process, for more parallelism you can do the following.

Generate the list of users by prompting, then write a file Users.csv with those email addresses, and a header row with the value User.

Make a gam batch file Users.bat that looks like this:
gam csv Users.csv gam <put first gam command arguments here specify ~User at the appropriate spot>
commit-batch
gam csv Users.csv gam <put second gam command arguments here specify ~User at the appropriate spot>
commit-batch
gam csv Users.csv gam <put third gam command arguments here specify ~User at the appropriate spot>
commit-batch

The commit-batch lines make sure that each command finishes before the next one starts; if two commands can run in parallel, omit the commit-batch.

Execute the batch (tbatch must be specified as there are multiple levels of parallelism)
gam tbatch Users.bat

Each gam command will run the users in parallel and multiple commands will be run in parallel in the absence of commit-batch.

Ross


On May 3, 2018, at 4:55 AM, Paul Horton <paul....@coopdigital.co.uk> wrote:

Paul Horton

unread,
May 3, 2018, 11:59:52 AM5/3/18
to GAM for G Suite
Ross, 

That looks like exactly what I need - just to confirm though, this is step-by-step what I need to do on multiple user (all the GAM commands have been tested to work on an individual user):

Gam tbatch deleteprep.bat:

gam csv todelete.csv gam user ~user collect orphans targetuserfoldername "Orphan Recover for Delete - #user#"

commit-batch

gam csv todelete.csv gam config auto_batch_min 1 redirect csv ~output multiprocess user ~user print filelist id title permissions


Which is fine, but then I need to run your two python scripts on the output CSVs to rejig the format so I get two lists in csv format showing ACLs and link shares for each file the user has. Once I've done that, I need to do the following (on each user I'm deleting, from the todelete.csv mentioned above):


gam csv olduserpermstodel.csv gam user ~Owner delete drivefileacl ~driveFileId ~permissionId

commit-batch

gam csv olduserlinksharesdel.csv gam user ~Owner delete drivefileacl ~driveFileId ~permissionId

commit-batch

gam user old...@domain.co.uk transfer drive archi...@domain.co.uk

commit-batch


Does that make sense? I'll have a list of users to delete, I recover the orphan files, then wipe the ACLs from all their docs, then transfer the docs to an archive user.

Thanks for your help!

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

Joe Romeo

unread,
Sep 20, 2019, 3:20:40 PM9/20/19
to GAM for G Suite
Paul,

Did you ever find a good way to do this? I think I'm in a similar situation. I have a tbatch .txt file with a lot of gam commands that works great. My problem is that halfway through I need to run a python script to manipulate a csv file, and then continue with a couple more gam commands.

So.

gam tbatch joes_file.txt

gam ...
commit-batch

gam ...
commit-batch

python file.py

gam ...
commit-batch

gam ...
commit-batch

Does that make sense? I don't know what my best option is other than to create two gam tbatch .txt files.

Ross Scroggs

unread,
Sep 20, 2019, 3:55:30 PM9/20/19
to google-ap...@googlegroups.com
Joe,

At the moment, two batch files is the way to go. Isit  that the python script is processing the output from the first set of commands?

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 view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/81ecc63e-aae4-4f3d-9746-3300fd052846%40googlegroups.com.


--

Joe Romeo

unread,
Sep 20, 2019, 4:02:58 PM9/20/19
to google-ap...@googlegroups.com
Exactly. I'll just split them into two batch files. Thanks!



--

Joe Romeo

Sr. System Administrator,

Corporate Applications

Sunrun

joe....@sunrun.com

 

Ross Scroggs

unread,
Sep 20, 2019, 5:31:24 PM9/20/19
to google-ap...@googlegroups.com
Joe,

I'm adding this to GAMADV-XTD3 4.94.14; stay tuned.

gam tbatch joes_file.txt

gam ...
commit-batch
gam ...
commit-batch
execute python file.py
commit-batch
gam ...
commit-batch
gam ...
commit-batch

Ross



--

Joe Romeo

unread,
Sep 20, 2019, 6:01:37 PM9/20/19
to google-ap...@googlegroups.com

Ross Scroggs

unread,
Sep 20, 2019, 8:18:33 PM9/20/19
to google-ap...@googlegroups.com
Joe,

Test it out: https://github.com/taers232c/GAMADV-XTD3/releases/tag/v4.94.14
You have to specify a full path to whatever program you're running.

Ross



--

Joe Romeo

unread,
Sep 21, 2019, 11:14:08 AM9/21/19
to google-ap...@googlegroups.com
That worked perfectly! Now we can nest python inside the GAM batch txt file! Very cool.

execute python file.py

Reply all
Reply to author
Forward
0 new messages