Orphan File Report

256 views
Skip to first unread message

James Twohill

unread,
Mar 5, 2024, 7:17:31 PM3/5/24
to GAM for Google Workspace
Hi All, 

I'm trying to run a GAM command to output a CSV file for orphaned files, but I need the following information to show in the CSV.

I'm running this command - gam redirect csv ./orphans.csv all users_ns_susp collect orphans preview which works fine, but I need these specific fields: 

  • account status i.e. Active, Suspended
  • Folder path
  • OU 
  • Last updated date
  • Orphan file size
  • Orphan file owner
Is this possible to do? 

Maj Marshall Giguere

unread,
Mar 6, 2024, 12:04:17 AM3/6/24
to google-ap...@googlegroups.com
James;

I'm assuming you are using advance gam. This will be a two step process.

First get all your users;

> gam redirect csv ./allusers.csv  print users fields ou,suspended 

The above command will get you all of your users plus their OU and suspended status.


Next pull all of the  top level orphan  file information for each user as below and merge the OU and status information from the previous output with it.

> gam redirect csv ./allorphans.csv multiprocess csv ./allusers.csv gam user ~primaryEmail print filelist choose orphans fields id,name,mimetype,modifiedTime,size,owners.emailaddress filepath depth 0 addcsvdata orgUnitPath ~orgUnitPath addcsvdata suspended ~suspended showownedby any

This will get only the top level orphans, so just the orphaned folders of anything that isn't at the root level.  I'm assuming that if you know the parent folder is an orphan all of its children still belong to the folder so you can manipulate the orphan folder and all it children will follow.  Here's a breakdown of the command:
1.  gam redirect csv ./allorphans.csv  - this will be the final output file
2. multiprocess csv ./allusers.csv - this tells gam to read each record from ./allusers.csv and process all the files for each users in the following gam command and merge it into the output
3 gam user ~primaryEmail print filelist choose orphans - tell gam to find all of the orphans for a single user from the input csv
4. fields id,name,mimetype,modifiedTime,size,owners.emailaddress, filepath depth 0 - tell gam what fields from the file search to send to the output
5. addcsvdata ourUnitPaht, ~ourUnitPaht addcsvdata suspended ~suspended - merge the OU and status from the input csv with each record
6. showownedby any  - select files owned by anyone, this is probably not necessary.

Depending on the size of your account this might take some time.



--
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/6c82248b-4ee3-4c31-984d-e8aa9a7e1a74n%40googlegroups.com.

James Twohill

unread,
Mar 6, 2024, 6:25:18 PM3/6/24
to GAM for Google Workspace
Thanks! Worked perfectly! 

James Twohill

unread,
Mar 6, 2024, 8:35:01 PM3/6/24
to GAM for Google Workspace
Hi Maj, 

One more question, I wanted to add whether it's a file or folder and first name last name. 

I've been trying to add it in there, but haven't had any success. 

On Wednesday 6 March 2024 at 16:04:17 UTC+11 Maj Marshall Giguere wrote:

Ross Scroggs

unread,
Mar 6, 2024, 9:14:30 PM3/6/24
to google-ap...@googlegroups.com
gam redirect csv ./allusers.csv  print users fields ou,suspended,name

gam redirect csv ./allorphans.csv multiprocess csv ./allusers.csv gam user ~primaryEmail print filelist choose orphans fields id,name,mimetype,modifiedTime,size,owners.emailaddress filepath depth 0 addcsvdata orgUnitPath ~orgUnitPath addcsvdata suspended ~suspended addcsvdata FirstName ~name.givenName addcsvdata LastName ~name.familyName showownedby any

Look at mimeType, it tells you the type of the file.

Ross
----
Ross Scroggs



Reply all
Reply to author
Forward
0 new messages