Help with adding a single user or group to multiple Shared Drives at once

951 views
Skip to first unread message

Andy Smith

unread,
Jun 20, 2019, 5:50:15 PM6/20/19
to GAM for G Suite
Hello all,

I've hunted high and low, and racked my brain for hours trying to get this done, only to be forced to continue to manually add users to each and every Shared Drive, one by one. There has to be a better way!

To give you an idea of what I'm trying to do:

We have about 60 Shared Drives in our GSuite environment. We have about 100 users, and probably 30 or so groups.
If I create a new user or group and would like to give that user or group permission to a Shared Drive, I have to go click on that drive and add it manually.
If I want to add that user or group to all 60 Shared Drives..... it's manual for every single one.

Is there a way I can do this programmatically through GAM? I found a couple of entries that looked promising, but when I tried them it didn't work the way I expected, so I'm hoping some GAM Gurus here can help me out!

Bradley Stinson

unread,
Jun 20, 2019, 6:28:22 PM6/20/19
to google-ap...@googlegroups.com
This is one way of doing it, there are probably better ways.

Note I didn't test this and would recommend testing it with a one or two users on just a couple of drives first. Also I use a mac so this is what it would look like running gam in Terminal.

If you have a single user who you've already added to all of them you can run the following. Or if you go through and add yourself to all of them as an owner you can do it this way too.
gam user <user...@domain.com> show teamdrives fields id > myTeamDrives.csv

That will make a csv with all the drives that user has access to and save it to your local hard drive. 
Then get another spreadsheet and give it a column header of driveid and paste each of those id's into that column. 
Give another column a header of users and list all of your users that need access to these drives in that column. Save your spreadsheet and return to your terminal window and run

gam csv <path/to/your/>myTeamDrives.csv gam user <user...@domain.com> add drivefileacl ~driveid user ~users role <whateverRoleYouWantThemToHave>

user...@domain.com is the user you added to the drive such as yourself, the user needs to have the privilege to add other users to the drive since gam is operating as that user.
gam csv tells gam that you will be referencing a csv. ~driveid and ~users tell gam to replace that part of command with what is in those columns. It will iterate over each one adding all of the users to all of the drives.
Roles that you can use to replace <whateverRoleYouWantTemToHave> can be seen at https://developers.google.com/drive/api/v3/reference/permissions they are the following.
  • owner
  • organizer
  • fileOrganizer
  • writer
  • commenter
  • reader

NOTICE: Information in this email and any attachments is confidential and may be legally privileged. It is intended solely for the addressee. If the reader of this message is not the intended recipient, or an agent responsible for delivering this message to the intended recipient, any disclosure, copying, distribution, or other use, is prohibited and may be unlawful. If you received this message in error, please notify the sender immediately by replying to this message and delete it from your computer. The Sender disavows any intention to create an electronic signature by means of this transmission.

--
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/4a462ea8-9b39-4803-8531-a48ca9cea932%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

+KimNilsson

unread,
Jun 23, 2019, 8:59:12 AM6/23/19
to GAM for G Suite
I think you can skip the initial user reference, as admin should be able to manage Shared Drives (previously Team Drives) without having access to them.
Reply all
Reply to author
Forward
0 new messages