Unshare all files and folders of GDrive for a specific User

183 views
Skip to first unread message

Linux_01

unread,
Jul 9, 2021, 4:43:01 AM7/9/21
to GAM for Google Workspace
Hello,

I want to unshare all files and folders shared with a Specific User. Those can be owned by anybody.
Do we have gam command to support this functionality?
Thank you.

Regards,
Linux_01

Ross Scroggs

unread,
Jul 9, 2021, 9:17:57 AM7/9/21
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/73376229-11b4-4a86-8436-0a17537a1832n%40googlegroups.com.

Linux_01

unread,
Jul 9, 2021, 11:11:48 AM7/9/21
to GAM for Google Workspace
Ross,

We have transferred TestUser Gdrive all files to DriveUser. Now want to unshare the files shared with TestUser.
I am curious and was trying for below mentioned method. Can it be achieved?

Please help.

A) Files owned by others shared with TestUser:
gam redirect stdout fileslist.csv user TestUser show filelist fullquery "sharedWithMe=True and not 'me' in owners"

List Owner, FileName and Webviewlink

B) Find the FileIDs of those files:
although Doesn't show up any output
gam user driveauser print filelist query "title='FileName'" id title 

C) Gam command to unshare those files ?

Thank you.

Linux_01

unread,
Jul 9, 2021, 11:28:39 AM7/9/21
to GAM for Google Workspace
Since the source user has lot of files shared, the gam command failed with error:
ERROR: GAM has run out of memory. If this is a large Google Workspace instance, you should use a 64-bit version of GAM on Windows or a 64-bit version of Python on other systems.

Can we achieve it in any other way?

Please help.

On Friday, July 9, 2021 at 6:47:57 PM UTC+5:30 Ross Scroggs wrote:

Ross Scroggs

unread,
Jul 9, 2021, 11:35:40 AM7/9/21
to google-ap...@googlegroups.com
The script reference I sent you has the steps documented to do what you want, did you follow them?

Ross



--

Linux_01

unread,
Jul 9, 2021, 11:38:17 AM7/9/21
to GAM for Google Workspace
Yes Ross,

I did follow but it failed in the 1st step itself due to less memory as mentioned in earlier mail.

Hence looking for workaround.

Ross Scroggs

unread,
Jul 9, 2021, 11:47:21 AM7/9/21
to google-ap...@googlegroups.com
Jyoti,

Send me a Meet/Zoom invitation.

Ross



--

Linux_01

unread,
Jul 9, 2021, 11:56:56 AM7/9/21
to GAM for Google Workspace
Ross,

Sent calendar invite to your gmail ID.

See you.

Thank you. 

Ross Scroggs

unread,
Jul 9, 2021, 11:57:19 AM7/9/21
to google-ap...@googlegroups.com
Jyoti,

gam redirect csv fileslist.csv user test...@domain.com show filelist fullquery "sharedWithMe=True and not 'me' in owners" fields id,name,owners.emailaddress


gam csv fileslist.csv gam user "~owners.0.emailAddress" delete drivefileacl "~id" test...@domain.com


Ross




--
Message has been deleted

Linux_01

unread,
Jul 12, 2021, 1:16:59 AM7/12/21
to GAM for Google Workspace
Ross,

I tried the commands for another user than we did during our google meeting and I am receiving below mentioned error when trying to unshare the files:

User: Ownerof...@domain.com, Drive File/Folder ID: 152ZX9AIL39FA5zfjnTcmx8Ux8jmod2-DqThz7YTbswc, Permission ID: 1xxxxxxxxxxxxxx4, Does not exist

Target Email ID doe exist.

Ross Scroggs

unread,
Jul 12, 2021, 9:29:16 AM7/12/21
to google-ap...@googlegroups.com
User A can share a file directly to User B, via a group that User B belongs to, via the domain that User B belongs to,
You're probably getting the error becase the file is not shared directly to User B.
Do: gam user Ownerof...@domain.com show drivefileacls 152ZX9AIL39FA5zfjnTcmx8Ux8jmod2-DqThz7YTbswc

Linux_01

unread,
Jul 12, 2021, 10:56:19 AM7/12/21
to GAM for Google Workspace
I followed the command to verify the File Permissions and I got below:

==============
gam user Ownerof...@domain.com show drivefileacls 1OknZ97nsyWSrCP2iQpkmODXZuLigx8oCm5PUcRln4l4
User: Ownerof...@domain.com, Show 1 Drive File/Folder
  Drive File/Folder ID: 1OknZ97nsyWSrOP2iQpkmODXZuLigxmnoCm5PUcRln4l4, Show 9 Permittees
    ddd (1/9)
      id: 17890050639992168932
      type: user
      emailAddress: d...@domain.com
      domain: domain.com
      role: writer
      deleted: False
    Cxyzi (2/9)
      id: 08546373272577874386
      type: user
      emailAddress: cx...@domain.com
      domain: domain.com
      role: writer
      deleted: False
    Jopa (3/9)
      id: 15255289471948704129
      type: user
      emailAddress: jo...@domain.com
      domain: domain.com
      role: writer
      deleted: False
   aksdr (4/9)
      id: 12826909368592751752
      type: user
      emailAddress: cp...@domain.com
      domain: domain.com
      role: reader
      deleted: False
   vbzx (5/9)
      id: 08856877292882090546
      type: user
      emailAddress: kk...@domain.com
      domain: domain.com
      role: reader
      deleted: False
 sl;lafl (6/9)
      id: 17865481294154763057
      type: user
      emailAddress: iu...@domain.com
      domain: domain.com
      role: reader
      deleted: False
    domain (7/9)
      id: 06653875062100232866k
      type: domain
      domain: domain.com
      role: reader
      allowFileDiscovery: False
;ls;ald (8/9)
      id: 12869505752492138818
      type: group
      emailAddress: lja...@domain.com
      domain: domain.com
      role: writer
      deleted: False
     (9/9)
      id: 04133896745072645906
      type: user
      emailAddress: Ownerof...@domain.com
      domain: domain.com
      role: owner
      deleted: False
===========================================

Linux_01

unread,
Jul 12, 2021, 10:58:30 AM7/12/21
to GAM for Google Workspace
Ross,

So in that case how can I unshare those files?

Linux_01

unread,
Jul 13, 2021, 5:01:09 AM7/13/21
to GAM for Google Workspace
Ross I have sent calendar invite for the meet. Please check

Linux_01

unread,
Jul 13, 2021, 8:01:35 AM7/13/21
to GAM for Google Workspace
Yes Ross these files seems to be shared via a group with the target user and it permissions shows that "role: reader" and "allowFileDiscovery: False"

Kim Nilsson

unread,
Jul 14, 2021, 4:55:48 PM7/14/21
to GAM for Google Workspace
Then TargetUser needs to be removed from that group, else TE will always retain access to those files.
Alternatively remove the group's permissions to the content, if it isn't necessary anymore.
Reply all
Reply to author
Forward
0 new messages