Skip to content

Users Drive Orphans

Ross Scroggs edited this page Oct 13, 2022 · 13 revisions

Users - Drive - Orphans

API documentation

Definitions

See Drive File Selection for symbols not listed here, such as <DriveFileEntity>

<DomainName> ::= <String>(.<String>)+
<EmailAddress> ::= <String>@<DomainName>
<UniqueID> ::= uid:<String>
<UserItem> ::= <EmailAddress>|<UniqueID>|<String>

<DriveFileName> ::= <String>
<DriveOrderByFieldName> ::=
        createddate|createdtime|
        folder|
        modifiedbyme|modifiedbymedate|modifiedbymetime|modifiedbyuser|
        modifieddate|modifiedtime|
        name|
        name_natural|
        quotabytesused|quotaused|
        recency|
        sharedwithmedate|sharedwithmetime|
        starred|
        title|
        title_natural|
        viewedbymedate|viewedbymetime

Collect orphaned files

Collect a users orphaned Drive files/folders into a target folder; only orphaned files not in the trash are processed.

gam <UserTypeEntity> collect orphans
        [(targetuserfoldername <DriveFolderName>)|(targetuserfolderid <DriveFolderID>)]
        [useshortcuts [<Boolean>]]
        (orderby <DriveOrderByFieldName> [ascending|descending])*
        [preview [todrive <ToDriveAttribute>*]]
  • targetuserfoldername <DriveFileName> - This is the parent folder name for the orphaned files; the default is "#user# orphaned files". In this string, #user# and #email# will be replaced by the source user email address, #username# will be replaced by the source user mail address without the domain. This folder will be created is necessary.
  • targetuserfolderid <DriveFolderID> - This is the parent folder ID for the orphaned files; it must exist.
  • useshortcuts false - Add the target user folder as a parent of an orphan if it can be done without affecting its access by other users; otherwise, put a shortcut to the orphan into the target user folder. This is the default behavior
  • useshortcuts or useshortcuts true - Put a shortcut to the orphan into the target user folder and do not modify the orphan's parents. GAM will not duplicate an existing shortcut.
  • orderby <DriveOrderByFieldName> [ascending|descending])* - Specify the order in which files are processed.
  • preview - If preview is specified, no files are collected; a CSV file listing the files to be collected is output.
  • todrive <ToDriveAttribute>* - When preview is specified, the CSV file can be uploaded to Google

Example

Collect a users orphaned files into the folder "Orphans - testuser@domain.com" on their My Drive; use shortcuts rather than changing the orphan's parents.

gam user testuser@domain.com collect orphans targetuserfoldername "Orphans - #user#" useshortcuts

Problem with useshortcuts false

  • testuser2 owns a file X1234 located in a folder owned by user testuser1 and shared with additional users
  • testuser1 removes testuser2's access to that folder
  • File 'X1234' now looks like an orphan to testuser2
  • gam user testuser2 collect orphans useshortcuts false
  • This moves X1234 to the folder testuser2 orphaned files; i.e., it has a new parent
  • testuser1 and all other users no longer have access to X1234 as it is now in a folder for which they have no access

Update History

Installation

Configuration

Notes and Information

Definitions

Command Processing

Collections

Client Access

Special Service Account Access

Service Account Access

Clone this wiki locally