Drive file counts for a user's private files and shared with other

193 views
Skip to first unread message

DJNinNZ

unread,
Apr 20, 2021, 9:57:21 PM4/20/21
to GAM for Google Workspace
Hi there,
I'm trying to get details on the general usage of Google Drive (G Suite Basic) for all users in the domain.

I aware of gam all users print filecounts will give the file counts for files a user owns but I'm also interested in diging deeper to find out

The number of private, non shared, files a users owns
The number of 'shared with others' files a user owns

looking at the API doco there is boolean field that indicates if a file is shared or not but trying to figure out the query to use that, looking at other posts print filecounts is perhaps not the way to go 

Regards
Duncan

Ross Scroggs

unread,
Apr 21, 2021, 12:37:24 AM4/21/21
to google-ap...@googlegroups.com
Duncan,

Here's an Advanced GAM solution:

Non-shared files
gam config csv_output_header_filter "User,Total" auto_batch_min 1 redirect csv NonShared.csv multiprocess redirect stdout - multiprocess redirect stderr stdout all users print filecounts pm not role owner em pma skip

config csv_output_header_filter "User,Total" - The only columns we want are User and Total
auto_batch_min 1 - turn on parallel processing
redirect csv NonShared.csv multiprocess - Output file, specify multiprocess as we're doing parallel processing
redirect stdout - multiprocess redirect stderr stdout - Clean up the progrss output
all users - everybody
print filecounts - What are we doing
pm not role owner em pma skip - If a file has a permission with a role other than owner, skip it


Shared files
gam config csv_output_header_filter "User,Total" auto_batch_min 1 redirect csv Shared.csv multiprocess redirect stdout - multiprocess redirect stderr stdout all users print filecounts pm not role owner em pma process

config csv_output_header_filter "User,Total" - The only columns we want are User and Total
auto_batch_min 1 - turn on parallel processing
redirect csv NonShared.csv multiprocess - Output file, specify multiprocess as we're doing parallel processing
redirect stdout - multiprocess redirect stderr stdout - Clean up the progrss output
all users - everybody
print filecounts - What are we doing
pm not role owner em pma process - If a file has a permission with a role other than owner, process it

Ross


The information contained in this email is privileged and confidential and intended for the addressee only. If you are not the intended recipient, please respect that confidentiality and do not disclose, copy or make use of its contents. If received in error, please destroy this email and contact the sender immediately. Thank you.

--
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/e10dce57-3992-46fc-86df-e88942d361efn%40googlegroups.com.

DJNinNZ

unread,
Sep 11, 2021, 11:06:02 PM9/11/21
to GAM for Google Workspace
Hi Ross,
really appreciate this, sorry it has taken so long to get back to you. 
I'm now trying to find files that may be shared with 'anyone in the domain' rather than explicitly via a group or user email in the domain.

Regards
Duncan

Brian Kim

unread,
Sep 12, 2021, 7:56:46 AM9/12/21
to GAM for Google Workspace
I think using print filecounts with pm domain yourdomain.com em should work.

Ross Scroggs

unread,
Sep 12, 2021, 11:21:21 AM9/12/21
to google-ap...@googlegroups.com
Brian's solution needs one more clause indicating that the scope of the ACL is domain.

print filecounts with pm type domain domain yourdomain.com em

Ross

DJNinNZ

unread,
Sep 12, 2021, 5:43:22 PM9/12/21
to GAM for Google Workspace
Hi there,
 really appreciate that.
would I need to list all domains that exists as primary or secondary domains or just the primary?

Regards
Duncan

Ross Scroggs

unread,
Sep 12, 2021, 6:54:12 PM9/12/21
to google-ap...@googlegroups.com
Duncan,


pm type domain em - will select files with a domain share to any domain
pm type domain domain primary.com em - will select files with a domain share to domain primary.com
pm type domain domainlist primary.com,secondary1.com,secondary2.com em - will select files with a domain share to domains primary.com,secondary1.com,secondary2.com

Ross



--

Brian Kim

unread,
Sep 13, 2021, 8:13:11 AM9/13/21
to GAM for Google Workspace
Looks like when you make a share with a secondary domain, the permission actually lists the primary domain.

Ross Scroggs

unread,
Sep 13, 2021, 11:06:06 AM9/13/21
to google-ap...@googlegroups.com
Duncan,

I've confirmed Brian's result that shares to a secondary domain map to shares in the primary domain.
pm type domain domain primary.com em - will select files with a domain share to domain primary.com and any of its secondary domains.

Ross




--
Reply all
Reply to author
Forward
0 new messages