Remove Multiple Users from Shared Drives

523 views
Skip to first unread message

Andrea Vail

unread,
Apr 19, 2023, 9:58:35 AM4/19/23
to GAM for Google Workspace
Hi everyone,

I've come across this very helpful post https://groups.google.com/g/google-apps-manager/c/MadU2DHzfMU/m/UlTW5S1gBQAJ to remove a single user from all shared drives they are a member of. It works great.

However, I'm looking to remove multiple users - basically everyone in our Leavers OU - from shared drives. Is there a way to do this with GAM? 

Thanks!

Kroo Bank Ltd is a company registered in England and Wales with company number 10359002. Registered office: LABS House, 15-19 Bloomsbury Way, London, WC1A 2TH. Kroo is authorised as a bank by the Prudential Regulation Authority and regulated by the Financial Conduct Authority and Prudential Regulation Authority (firm registration number 953772). Kroo is separately registered as a payment services / electronic money agent of Modulr FS Limited under registration number 902797.

Confidentiality caution: This email and any attachments are intended solely for the intended recipient(s) and may contain confidential information. Unless you are an intended recipient, the distribution, copying or disclosure of any information contained in the message would be unlawful. If you have received this email by mistake, please notify the sender by email and then permanently delete the email you received and your reply.
Privacy information for our contacts: Kroo respects your data protection rights. We do collect and use information about our business contacts. If you are one of them you can find out more by clicking here to see our Contacts Privacy Notice, which tells you what information we collect and why, and explains your rights.
Please consider the environment before printing this email.

Rance Hall

unread,
Apr 19, 2023, 10:07:54 AM4/19/23
to google-ap...@googlegroups.com

Andrea:

 

You can supply a CSV file list of users and have a command run repeatedly for each.

 

How you do this depends on which version of GAM you are running.

 

For Ross’ Advanced GAM: https://github.com/taers232c/GAMADV-XTD3/wiki/Bulk-Processing#csv-files

 

I don’t recall Jay’s original GAM well enough to know where to tell you to look, maybe someone else on the list can help with that.

 

-- 

Rance Hall

ESU10 Network Services

rance...@esu10.org

308-698-1919

 

 

 

From: google-ap...@googlegroups.com <google-ap...@googlegroups.com> on behalf of Andrea Vail <andre...@kroo.com>
Date: Wednesday, April 19, 2023 at 8:58 AM
To: GAM for Google Workspace <google-ap...@googlegroups.com>
Subject: [GAM] Remove Multiple Users from Shared Drives

[EXTERNAL EMAIL]

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/420997df-f99f-42fa-b2e0-4ca0025e197dn%40googlegroups.com.

Ross Scroggs

unread,
Apr 19, 2023, 10:51:47 AM4/19/23
to google-ap...@googlegroups.com

Advanced GAM


Make a file Users.csv with one column: User

User

us...@domain.com

us...@domain.com

...


Get users's Shared Drive access                                                                                                                                                                    

                                                                                                                                                                                                   

gam redirect csv ./UsersSharedDrives.csv multiprocess csv Users.csv gam user "~User" print shareddrives fields id,name                                                                             

                                                                                                                                                                                                   

Delete user's Shared Drive access                                                                                                                                                                 \


gam redirect stdout ./DeleteSharedDriveAccess.csv multiprocess redirect stderr stdout csv ./UsersSharedDrives.csv gam delete drivefileacl "~id" "~User"


Ross




--

Andrea Vail

unread,
Apr 20, 2023, 9:28:28 AM4/20/23
to GAM for Google Workspace
Thank you Ross, that worked perfectly!

Alan Ho

unread,
Oct 25, 2023, 9:33:54 AM10/25/23
to GAM for Google Workspace
Just came across this and it's amazing! Thank you, Ross!

Could this be used to remove users from all files shared with them? If so, how would that be handled?

Ross Scroggs

unread,
Oct 25, 2023, 10:42:04 AM10/25/23
to google-ap...@googlegroups.com
# Get files shared with users

gam redirect csv ./SharedToUserFiles.csv multiprocess csv Users.csv gam user "~User" print filelist showownedby others fields id,name,mimetype,owners.emailaddress

# Inspect SharedToUserFiles.csv, verify that it makes sense

# Delete the ACLs sharing the files

gam redirect stdout ./DeleteSharedToUserACLs.csv multiprocess redirect stderr stdout csv ./SharedToUserFiles.csv gam user "~owners.0.emailAddress" delete drivefileacl "~id" "~Owner"

If users outside of your domain have shared files to your users, thos ACLs can't be deleted.

Ross
----
Ross Scroggs



Alan Ho

unread,
Oct 25, 2023, 11:04:49 AM10/25/23
to GAM for Google Workspace
Amazing! Thank you so much, Ross!
Reply all
Reply to author
Forward
0 new messages