How to find and restict all files in an organization with "Anyone with the link"?

110 views
Skip to first unread message

Lior W.

unread,
Apr 13, 2021, 9:39:43 AM4/13/21
to GAM for Google Workspace
Hi,

My goal is to simulate File exposure report without having the relevant edition, and then act on it.

The output I need is:
Owner - file id - file name - permission type

Back here Ross brilliantly showed how to find such files by:
With Standard GAM:
export GAM_CSV_ROW_FILTER="permissions.*.id:regex:anyoneWithLink"

export GAM_CSV_HEADER_FILTER="Owner,id,title,permissions.*.type,permissions.*.withLink"

gam all users print filelist id title permissions todrive > testing.log

With Advanced GAM:
gam redirect csv - todrive redirect stdout testing.log all users print filelist fields id,name,permissions.type,permissions.allowfilediscovery pm type anyone allowfilediscovery false em

Standard GAM uses Drive Rest v2 API and Advanced GAM uses Drive Rest v3 API
In v2, withLink = True is the same as allowFileDiscovery = False in V3

But:
  1. For standard GAM, How to I later unload these exports? Should I restart the terminal?
  2. What if I want to just automatically convert these files to Restricted? Can you show me the proper GAM/GAMADV-XTD3 commands? Can you pleasee show me both with and without specifying the Owner (in cases when only a certain owner needs their files converted and not everybody)?
Thanks!!!!!!

anyone with the link.png

Trevor Scanlan

unread,
Apr 13, 2021, 9:53:51 AM4/13/21
to GAM for Google Workspace
https://sites.google.com/jis.edu.bn/gam-commands/services/drive#h.p_qBJ2c0JIiPr_

Remove "Anyone with the Link" Settings
gam user <user email address> delete drivefileacl <file ID> anyonewithlink

Ross Scroggs

unread,
Apr 13, 2021, 10:55:57 AM4/13/21
to google-ap...@googlegroups.com
Lior,

unset GAM_CSV_ROW_FILTER
unset GAM_CSV_HEADER_FILTER

Trevor showed the basic command, from a CSV file produced from the print filelist command.

gam csv AnyoneWithLink.csv gam user "~Owner" delete drivefileacl "~id" anyonewithlink

Delete the rows from the CSV files for owners whose files you don't want to change.

Ross

--
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/ef47e4ee-afab-4665-93ac-082492023cben%40googlegroups.com.


--

Lior W.

unread,
Apr 13, 2021, 3:40:57 PM4/13/21
to GAM for Google Workspace
Sorry, but it's a bit confusing:
  1. Will those deletion commands work in Standard GAM?
  2. I don't want to delete files with "Anyone with the link", just to change them to Restricted. How can it be done?
  3. If I don't use unset, will it still get unset once I restart the Terminal?
Thanks!

Ross Scroggs

unread,
Apr 13, 2021, 3:47:27 PM4/13/21
to google-ap...@googlegroups.com
Lior,

1. Yes
2. gam user "~Owner" delete drivefileacl "~id" anyonewithlink deletes the ACL, not the file
3. Yes

Ross

Lior W.

unread,
Apr 14, 2021, 6:22:06 AM4/14/21
to GAM for Google Workspace
That's amazing, thanks!

Regarding the search, in order to look just through an individual user, will it be (note the bold parts)?
With Standard GAM:
export GAM_CSV_ROW_FILTER="permissions.*.id:regex:anyoneWithLink"

export GAM_CSV_HEADER_FILTER="Owner,id,title,permissions.*.type,permissions.*.withLink"

gam user <e-mail> print filelist id title permissions todrive > testing.log

With Advanced GAM:
gam redirect csv - todrive redirect stdout testing.log user <e-mail> print filelist fields id,name,permissions.type,permissions.allowfilediscovery pm type anyone allowfilediscovery false em


Regarding the permission deletion, is it possible to give it the Google Spreadsheet (or CSV, if it's big) instead of having to download it only in order to upload it locally?
Reply all
Reply to author
Forward
0 new messages