Need help to export a report of Google Shared Drives files/folders that are shared with external contacts

281 views
Skip to first unread message

Jovy Javier

unread,
Aug 25, 2023, 1:05:38 PM8/25/23
to GAM for Google Workspace
Good day.

We'd like to audit which Google Drive files and folders are shared with external contacts. We would like to see a list of files with a corresponding list of users that have access to it including the external contact's email.

We've tried a command with file list permissions but doesn't appear to show external contacts in the exported report and the doesn't show the folder name - it's using the folder ID.

Thank you.

Ross Scroggs

unread,
Aug 25, 2023, 1:19:02 PM8/25/23
to google-ap...@googlegroups.com

--
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/4213b9e5-c5e1-4410-a52d-3d8298b9f676n%40googlegroups.com.


--

Jovy Javier

unread,
Aug 31, 2023, 11:45:57 AM8/31/23
to google-ap...@googlegroups.com
Hi Ross,

Thank you for responding. Would you happen to have a guide that does not require Python?

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/Jckf4EMU8AM/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/CAJkvRS9daU%2Bm%3D4JjM0SNtZY7zQ%3D1wBWA%3DrNg6tyXi0wjHKAZEw%40mail.gmail.com.


--
Jovy Javier Response Team Technician jo...@reachoutit.com | (888) 845-1113 ReachOut Technology | desk

Ross Scroggs

unread,
Aug 31, 2023, 11:54:34 AM8/31/23
to google-ap...@googlegroups.com
Jovy,

Try this:
gam user us...@domain.com print filelist fields id,name,mimetype,basicpermissions pm not domain domain.com em pmfilter oneitemperrow

Send me a Meet/Zoom invitation

Ross
----
Ross Scroggs



Jovy Javier

unread,
Sep 6, 2023, 9:56:21 AM9/6/23
to google-ap...@googlegroups.com
Good morning Ross,

Thank you for the command.I tried the command and it looks like it has the info that we need. I see some external emails there. Is there a version to run it for all users?
Is it also possible to get a report by shared drive name instead of per user?

Ross Scroggs

unread,
Sep 6, 2023, 12:04:19 PM9/6/23
to google-ap...@googlegroups.com
Jovy,

All users My Drive
gam config auto_batch_min 1 num_threads 20 redirect csv ./ExternallySharedFiles.csv multiprocess redirect stdout - multiprocess redirect stderr stdout all users print filelist fields id,name,mimetype,basicpermissions pm not domain domain.com em pmfilter oneitemperrow

config auto_batch_min 1 - turn on parallel processing
num_threads 20 - do 20 users in parallel
Choose one of the following tow choices
redirect csv ./ExternallySharedFiles.csv multiprocess - Write the data to a local file
redirect csv - multiprocess todrive - Write the data to a Google sheet
redirect stdout - multiprocess redirect stderr stdout - Clean progress messages


Shared Drive
You have to know an organizer of the drive
gam config csv_output_header_drop_filter "permission.permissionDetails,permission.photoLink" redirect csv ./ExternallySharedSharedDriveFiles.csv user orga...@domain.com print filelist select teamdriveid <ID of SharedDrive> fields id,name,mimetype,basicpermissions pm not domain domain.com em pmfilter oneitemperrow
gam config csv_output_header_drop_filter "permission.permissionDetails,permission.photoLink" redirect csv ./ExternallySharedSharedDriveFiles.csv user orga...@domain.com print filelist select teamdrive <Name of SharedDrive> fields id,name,mimetype,basicpermissions pm not domain domain.com em pmfilter oneitemperrow

Ross

----
Ross Scroggs


Fadhli F

unread,
Sep 6, 2023, 1:12:53 PM9/6/23
to GAM for Google Workspace
Hey,

How to make it for multiple domains? 

thanks

Ross Scroggs

unread,
Sep 6, 2023, 1:15:09 PM9/6/23
to google-ap...@googlegroups.com

Nahuel Rodríguez

unread,
Jun 20, 2024, 7:27:39 AMJun 20
to GAM for Google Workspace
Hello, I tried running this on my recently installed GAM 

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 <mydomain> em pmfilter oneitemperrow

but I'm getting the following error:

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

What could I've failing at?

Thanks!!

Nahuel Rodríguez

unread,
Jun 20, 2024, 8:35:57 AMJun 20
to GAM for Google Workspace
Done, it was just upgrading to GAM ADV. Thanks!!

Nahuel Rodríguez

unread,
Jun 21, 2024, 3:51:18 AMJun 21
to GAM for Google Workspace
Hi Ross, bothering you with a quick one. I have a massive Shared Drive (480 Gbs or so) and when I try to run this:


gam config csv_output_header_drop_filter "permission.permissionDetails,permission.photoLink" redirect csv ./ExternallySharedSharedDriveFiles.csv user orga...@domain.com print filelist select teamdrive <Name of SharedDrive> fields id,name,mimetype,basicpermissions pm not domain domain.com em pmfilter oneitemperrow

It always gets stuck at some point, sometimes it's 5000 Drive/Files, others is 12000, but at some point it stops counting and never ends.

Is there any tip on how to make it in batches or, perhaps, avoid getting it frozen?

Thanks as usual


Ross Scroggs

unread,
Jun 21, 2024, 10:25:10 AMJun 21
to google-ap...@googlegroups.com
Nahuel,

Let's turn on debugging and see what going on when it hangs.

gam config  debug_level 1 csv_output_header_drop_filter "permission.permissionDetails,permission.photoLink" redirect csv ./ExternallySharedSharedDriveFiles.csv user orga...@domain.com print filelist select teamdrive <Name of SharedDrive> fields id,name,mimetype,basicpermissions pm not domain domain.com em pmfilter oneitemperrow

When it hangs, send me (directly, not to the group) the last 100 lines of output on the screen.

Ross

----
Ross Scroggs



Ross Scroggs

unread,
Jun 21, 2024, 10:29:54 AMJun 21
to google-ap...@googlegroups.com
Replace: pm not domain domain.com em
With: pm not domainlist domain1.com.domain2.com,domain3.com em

Ross
----
Ross Scroggs


On Sep 6, 2023, at 10:12 AM, Fadhli F <fadhlifat...@gmail.com> wrote:

Romych

unread,
Jul 9, 2024, 6:24:50 AM (8 days ago) Jul 9
to GAM for Google Workspace
Hi, Ross. I used your command to show to whom one of my employees was sharing externally (Outside the organization files), can you tell me if there is a command to find out to whom a specific SharedDrive is shared - externally, to get a list of external users who have access to a specific SharedDrive with the name Cat?

I found this command -                                 gam print drivefileacls teamdrive "Golgafrincham" pm role organizer em pm role fileorganizer em oneitemperrow                                                              but idk its the same or not?


And is there a command to get a list of shared files to external users on SharedDriv Kot? Those. on SharedDrive Cat get a list of files or folders, most likely files that are shared with external users and output it to a file?

Thank you.

пятница, 21 июня 2024 г. в 17:25:10 UTC+3, Ross Scroggs:

Ross Scroggs

unread,
Jul 9, 2024, 10:50:38 AM (8 days ago) Jul 9
to google-ap...@googlegroups.com
In these examples, replace domain.com with your domain.
This command will show members of a Shared Drive that are not in your domain.
gam print drivefileacls teamdrive "Name of Shared Drive" pm not domain domain.com em oneitemperrow

This command will show files/folders on a Shared Drive shared to users not in your domain.
gam redirect csv ./ExternallySharedSharedDriveFiles.csv user orga...@domain.com print filelist select teamdrive "Name of SharedDrive>\" fields id,name,mimetype,basicpermissions pm not domain domain.com em pmfilter oneitemperrow

Ross
----
Ross Scroggs



Maj Marshall Giguere

unread,
Jul 9, 2024, 9:47:45 PM (7 days ago) Jul 9
to google-ap...@googlegroups.com
To find all the non domain acls for  a shared drive you will need to pull the file list for the entire drive.

$> gam redirect csv ./nondomainacls.csv user drivem...@mydomain.com print filelist select teamdrive "Cat" oneitemperrow filepath fields id,name,basicpermissions pmfilter pm deleted false inherited false notdomain '^mydomain.com$' em

The above will produce a CSV file with any ACL not within your domain including the email address of the ACL target.  The "user" must be someone that has organizer (manager privileges) on the drive.



Romych

unread,
Jul 10, 2024, 3:43:14 AM (7 days ago) Jul 10
to GAM for Google Workspace
Good day, thank you all of google-apps-managers. Thank you very much, it is very powerful and you are very powerfull team, it did 95% of what I expected. Now I am looking for "fields" that would help me display the "tree", or more precisely the "filepath", where the file is located. Otherwise the picture is as follows: in the name field, only the file name is displayed to me. I went to the API page to look for "fields" to get something like this in one of the columns: Cat(SharedDrive)/Tails(folder)/leopard.txt(file), or just Cat/Tails/leopard I found a field - parents, but this is not what I need. Perhaps you can tell me again which field I need, if such a case exists?

Most likely this will not work and you will need to write a Python.py script...as I understand it( Okay, then the question is, can I use the same command as for the shared drive, but not exactly for it, but for the folder that is located in it? Those. I checked SharedDrive "Cat", but I need the same for Tails (folder) shared drive folder?


Thank you.

вторник, 9 июля 2024 г. в 17:50:38 UTC+3, Ross Scroggs:

Ross Scroggs

unread,
Jul 10, 2024, 9:47:07 AM (7 days ago) Jul 10
to google-ap...@googlegroups.com

Maj Marshall Giguere

unread,
Jul 10, 2024, 5:07:30 PM (6 days ago) Jul 10
to google-ap...@googlegroups.com
If you followed my template the "filepath" keyword would include the file path as "path.0" in the output csv file.  You would see something like this in the CSV as path.0:

SharedDrives/BArch/A1/Shared outside domain

One thing to keep in mind is that if the external user has access to a folder you won't see anything below that as the command included the pm filter option "inherited false".

Romych

unread,
Jul 11, 2024, 7:56:56 AM (6 days ago) Jul 11
to GAM for Google Workspace
Hi, okay, thank you. I know, i used your command, as I understand it, it differs from Ross’s command in that for you it only returns directories, or not all files. With this command -  gam redirect csv ./ExternallySharedSharedDriveFiles.csv user orga...@domain.com print filelist select teamdrive "Name of SharedDrive>\" fields id,name,mimetype,basicpermissions pm not domain domain.com em pmfilter oneitemperrow       I get the output of absolutely all files.

And I also tried to do something similar for folders on shareddrive, but I got no results. Like example for SharedDrvie its SharedDrvies/BArch/A1/Shared - its okay. For folder i  need for the folder I need to get the same thing, but starting from the folder: BArch/A1/Shared
I tried something like this:  gam print drivefileacls 0A14444444444444432 oneitemperrow fields displayname,emailaddress,role todrive
and instead of the ID I used quotes and entering a folder, but I didn’t get any results...  gam print drivefileacls "BArch" oneitemperrow fields displayname,emailaddress,role todrive
I don’t know yet whether I need this, but I’m moving in this direction, which means it’s necessary

четверг, 11 июля 2024 г. в 00:07:30 UTC+3, Maj Marshall Giguere:

Ross Scroggs

unread,
Jul 11, 2024, 1:27:12 PM (6 days ago) Jul 11
to google-ap...@googlegroups.com
To start at a particular folder do this:
Get the ID of the folder: BArch/A1/Shared
gam redirect csv ./ExternallySharedSharedDriveFiles.csv user orga...@domain.com print filelist select  "<ID of folder>" fields id,name,mimetype,basicpermissions pm not domain domain.com em pmfilter oneitemperrow

Ross
----
Ross Scroggs


Reply all
Reply to author
Forward
0 new messages