We recently did this in one organisation.
Using GAMADV-XTD3, though regular GAM also works.
But, to make it easier on you, you should grab an extra script.
Add your organisation's domain/s as the DOMAIN_LIST values.
Also set DESIRED_ALLOWFILEDISCOVERY = 'True'
Depending on version of GAM read the instructions on how to create the filelistperms.csv file.
Run the filter command script, like this.
python GetSharedWithDomainDriveACLs.py filelistperms.csv deleteperms.csv
As it says, check the deleteperms.csv file to make sure it (only) has the ACLs you wish to remove.
Then delete those ACLs.
gam csv deleteperms.csv gam user "~Owner" delete drivefileacl "~driveFileId" "~permissionId"
In our case we also had a lot of files shared to
Anyone Without Link. So Ross helped us set up a combined GAMADV-XTD3 syntax for grabbing both types at once into a single file, which then could be filtered with aforementioned script
and it's cousin. We added the time bit just to make sure we got a visibly complete process run and no hidden crash, since it had to gather data from thousands of users. As you can see, we also based the scope of users on a list of OUs where staff reside, so we didn't have to touch student data. Note that this command doesn't work with regular GAM.
time gam config auto_batch_min 1 redirect csv ./filelistperms.csv multiprocess csvdatafile ous_ns StaffOUs.csv:OU print filelist showmimetype not gsite id title permissions pm type domain withlink false em pm type anyone withlink false em pmm or