Getting files shared with External accounts in Shared drives and mydrive

451 views
Skip to first unread message

Aleksejs Sitdikovs

unread,
Mar 20, 2024, 7:29:33 AM3/20/24
to GAM for Google Workspace
Hello, 
Is it possible to get files and folders, which were shared with external email addresses in shared drives and my drive?
First task is to find out and second is to delete user from files/folders ACL. 

I tried to run this command: 
gam user ad...@domain.com print filelist fields id,name,driveid corpora alldrives query "'exte...@domain.com' in writers or 'external.com" todrive tdtitle "external.com External and MyDrive"

But it only find files in shared drive ( my admin account is manager of all shared drives). Despite the flad "corpora alldrives" it is not checking all drives. Am I missing something or it is not possible by design?

Thank you,
Cheers

Ross Scroggs

unread,
Mar 20, 2024, 9:42:57 AM3/20/24
to google-ap...@googlegroups.com
You will have to find the shares for each user's My Drive by running a command for each user.

The query does not look correct.

Ross
----
Ross Scroggs



--
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/6cd2362b-fe8e-47e2-b1ea-ba5397c0d4e3n%40googlegroups.com.

Aleksejs Sitdikovs

unread,
Mar 20, 2024, 9:54:13 AM3/20/24
to GAM for Google Workspace
Hello Ross,

This script will search only "My drive" or MyDrive and Shared drive?
Or for Shared drive I need additional script?

Cheers,
Alex

Ross Scroggs

unread,
Mar 20, 2024, 11:37:29 AM3/20/24
to google-ap...@googlegroups.com

Aleksejs Sitdikovs

unread,
Mar 21, 2024, 5:56:45 AM3/21/24
to GAM for Google Workspace
Hello Ross,
thank you for the script. After taking some time to understand how it works, I got strange behaviour.
When I run this command: 

gam config auto_batch_min 1 redirect csv ./filelistperms.csv multiprocess all users print filelist fields id,title,permissions,owners.emailaddress,mimetype pm type user notrole owner em pmfilter

It creates csv file and some emails addresses are capilased, which makes problem when I run this python script to create csv to delete ACLs, as name.s...@external.com doesn't produce anything, but Name.S...@external.com does does create.

Question is, is it possible from the first command: gam config auto_batch... to create a csv file with all emails in ACLs with lower case? Or what options are available to optimise the script, so it would be able to match strings.

Cheers,
Aleksejs

T. Nguyen

unread,
Mar 26, 2024, 12:58:56 PM3/26/24
to GAM for Google Workspace
Hello Aleksejs,

I'm also having the same problem, I wonder if you have any solution for this

Ross Scroggs

unread,
Mar 26, 2024, 1:11:25 PM3/26/24
to google-ap...@googlegroups.com
In the script, change these two lines:
      emailAddress = row[f'permissions.{permissions_N}.emailAddress']
      domain = row[f'permissions.{permissions_N}.domain']
to:
      emailAddress = row[f'permissions.{permissions_N}.emailAddress'].lower()
      domain = row[f'permissions.{permissions_N}.domain'].lower()

Ross

----
Ross Scroggs



Aleksejs Sitdikovs

unread,
Mar 27, 2024, 4:57:24 AM3/27/24
to GAM for Google Workspace
Thank you Ross, that did work.

I ended up not using the script for Shared Drives(Team drive), as for some reason it was not returning all users, which match criteria from csv file to new deleteperms.csv.
Manually searching them in filelistperms.csv I was able to find them, but not in deleteperms.csv for some reason. 
And It was taking way to long, to create csv file with all the permission, so I ended up not using it.
Instead I ended up using:
To create list for shared drives:
gam user share-dr...@domain.com print filelist fields id,name,driveid corpora alldrives query "'exte...@domain.com' in writers or 'exte...@domain.com' in readers" | gam csv - gam user "~Owner" delete drivefileacl "~id" exte...@domain.com todrive tdtitle "File name" And to find and delete: 
gam user share-dr...@domain.com print filelist fields id,name,driveid corpora alldrives query "'exte...@domain.com' in writers or 'exte...@domain.com' in readers" | gam csv - gam user "~Owner" delete drivefileacl "~id" exte...@domain.com

This works much faster. Thank you for your assistance. Have a great day.

Nahuel Rodríguez

unread,
Jun 20, 2024, 7:27:39 AM6/20/24
to GAM for Google Workspace
Hello everyone. 
I'm new to GAM and trying to run this command:

gam config auto_batch_min 1 num_threads 20 redirect csv multiprocess todrive all users print filelist fields id,name,title,mimetype,owners.emailaddress,permissions pm not domain <domain.com> em pmfilter oneitemperrow

but I'm getting 

ERROR: config is not a valid argument for "gam"

Could you please give any hint on what I might be failing at?

Thanks!

Ross Scroggs

unread,
Jun 20, 2024, 9:24:34 AM6/20/24
to google-ap...@googlegroups.com
You're running Standard GAM, the command is for Advanced GAM.


Ross
----
Ross Scroggs


Nahuel Rodríguez

unread,
Jun 20, 2024, 9:27:36 AM6/20/24
to google-ap...@googlegroups.com
Yep, just figured it out. Such a newbie. Thanks!

You received this message because you are subscribed to a topic in the Google Groups "GAM for Google Workspace" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-apps-manager/J5g8lFvUqtg/unsubscribe.
To unsubscribe from this group and all its topics, 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/99DE739D-FEC1-4158-A699-C59EC408F7B3%40gmail.com.


--
Logo
Nahuel Rodriguez | IT Engineer
e: nahuel.r...@belvo.com
www.belvo.com
twitter icon linkedin icon 
Reply all
Reply to author
Forward
0 new messages