# Domain Administrators - Shared Drives - [API documentation](#api-documentation) - [Query documentation](#query-documentation) - [Definitions](#definitions) - [Introduction](#introduction) - [GUI API permission name mapping](#gui-api-permission-name-mapping) - [Display Shared Drive themes](#display-shared-drive-themes) - [Manage Shared Drives](#manage-shared-drives) - [Create a Shared Drive](#create-a-shared-drive) - [Bulk Create Shared Drives](#bulk-create-shared-drives) - [Update Shared Drive settings](#update-shared-drive-settings) - [Delete a Shared Drive](#delete-a-shared-drive) - [Change Shared Drive visibility](#change-shared-drive-visibility) - [Display Shared Drives](#display-shared-drives) - [Display List of Shared Drives in an Organizational Unit other than /](#display-list-of-shared-drives-in-an-organizational-unit-other-than-) - [Display List of Shared Drives in an Organizational Unit](#display-list-of-shared-drives-in-an-organizational-unit) - [Display all Shared Drives with no members](#display-all-shared-drives-with-no-members) - [Display all Shared Drives with no organizers](#display-all-shared-drives-with-no-organizers) - [Display all Shared Drives with a specific organizer](#display-all-shared-drives-with-a-specific-organizer) - [Display all Shared Drives without a specific organizer](#display-all-shared-drives-without-a-specific-organizer) - [Manage Shared Drive access](#manage-shared-drive-access) - [Transfer Shared Drive access](#transfer-shared-drive-access) - [Display Shared Drive access](#display-shared-drive-access) - [Display Shared Drive access for specific Shared Drives](#display-shared-drive-access-for-specific-shared-drives) - [Display Shared Drive access for selected Shared Drives](#display-shared-drive-access-for-selected-shared-drives) - [Display members of all Shared Drives](#display-members-of-all-shared-drives) - [Display external members of all Shared Drives](#display-external-members-of-all-shared-drives) - [Display ACLs for Shared Drives with no organizers](#display-acls-for-shared-drives-with-no-organizers) - [Display ACLs for Shared Drives with all organizers outside of your domain](#display-acls-for-shared-drives-with-all-organizers-outside-of-your-domain) - [Display ACLs for Shared Drives with all ACLs outside of your domain](#display-acls-for-shared-drives-with-all-acls-outside-of-your-domain) - [Clean up scammed Shared Drives](#clean-up-scammed-shared-drives) ## API documentation * [Drive API - Drives](https://developers.google.com/drive/api/reference/rest/v3/drives) * [Drive API - Files](https://developers.google.com/drive/api/reference/rest/v3/files) * [Manage Shared Drives](https://developers.google.com/drive/v3/web/manage-teamdrives#managing_team_drives_for_domain_administrators) * [Move content to Shared Drives](https://support.google.com/a/answer/7374057) * [Shared Drive Limits](https://support.google.com/a/users/answer/7338880) * [Shared Drives in Org Units](https://support.google.com/a/answer/7337635) ## Query documentation * [Shared Drives Search](https://developers.google.com/drive/api/guides/search-shareddrives) ## Definitions ``` ::= "#" ::= asparagus|bluevelvet|bubblegum|cardinal|chocolateicecream|denim|desertsand| earthworm|macaroni|marsorange|mountaingray|mountaingrey|mouse|oldbrickred| pool|purpledino|purplerain|rainysky|seafoam|slimegreen|spearmint| toyeggplant|vernfern|wildstrawberries|yellowcab ::= aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond| blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral| cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray| darkgrey|darkgreen|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid| darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkslategrey| darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue| firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod| gray|grey|green|greenyellow|honeydew|hotpink|indianred|indigo|ivory|khaki| lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan| lightgoldenrodyellow|lightgray|lightgrey|lightgreen|lightpink|lightsalmon| lightseagreen|lightskyblue|lightslategray|lightslategrey|lightsteelblue| lightyellow|lime|limegreen|linen|magenta|maroon|mediumaquamarine|mediumblue| mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen| mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin| navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid| palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff| peru|pink|plum|powderblue|purple|red|rosybrown|royalblue|saddlebrown|salmon| sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray| slategrey|snow|springgreen|steelblue|tan|teal|thistle|tomato|turquoise|violet| wheat|white|whitesmoke|yellow|yellowgreen ::= | ::= | ``` ``` ::= (json [charset ] ) | (json file [charset ]) | ::= id: ::= /|(/)+ ::= | ::= See: https://docs.python.org/3/library/re.html ::= ::= ::= > ::= createddate|createdtime| folder| lastviewedbyme|lastviewedbymedate|lastviewedbymetime|lastviewedbyuser| modifiedbyme|modifiedbymedate|modifiedbymetime|modifiedbyuser| modifieddate|modifiedtime| name| name_natural| quotabytesused|quotaused| recency| sharedwithmedate|sharedwithmetime| starred| title| title_natural| viewedbymedate|viewedbymetime ::= manager|organizer|owner| contentmanager|fileorganizer| contributor|writer|editor| commenter| viewer|reader ::= anyone|domain|group|user ::= anyone|anyonewithlink| user:|group:| domain:|domainwithlink:; ::= anyone|anyonewithlink|id: ::= | ::= "(, ::= "(,)*" ::= | | | | | See: https://github.com/GAM-team/GAM/wiki/Collections-of-Items ::= | | | | | See: https://github.com/GAM-team/GAM/wiki/Collections-of-Items ::= additionalroles| allowfilediscovery| deleted| displayname|name domain| emailaddress| expirationdate| expirationtime| id| permissiondetails| photolink| role| teamdrivepermissiondetails| type| withlink ::= "(,)*" ::= See: https://developers.google.com/drive/api/v3/search-parameters ::= manager|organizer|owner| contentmanager|fileorganizer| contributor|writer|editor| commenter| viewer|reader ::= "(,)*" ::= ::= ::= | (teamdriveid )|(teamdriveid:)| (teamdrive )|(teamdrive:) ::= backgroundimagefile| backgroundimagelink| capabilities| colorrgb| createdtime| id| name| themeid ::= "(,)*" ::= |(teamdriveid )|(teamdriveid:) ::= (teamdrive )|(teamdrive:) ::= (teamdriveadminquery )|(teamdriveadminquery:) ::= | | ::= adminmanagedrestrictions| allowcontentmanagerstosharefolders| copyrequireswriterpermission| domainusersonly| drivemembersonly|teammembersonly| sharingfoldersrequiresorganizerpermission Each pair of restrictions below are equivalent: allowcontentmanagerstosharefolders true sharingfoldersrequiresorganizerpermission false allowcontentmanagerstosharefolders false sharingfoldersrequiresorganizerpermission true ``` ## Introduction A domain administrator with the Drive and Docs administrator privilege can search for Shared Drives or update permissions for Shared Drives owned by their organization, regardless of the admin's membership in any given Shared Drive. Three forms of the commands are available: * `gam action ...` - The administrator named in oauth2.txt is used, domain administrator access implied * `gam action ... adminaccess` - The user named in `` is used, adminaccess indicates that the user is a domain administrator * `gam action ...` - The user named in `` is used, access is limited to drives for which they are an organizer ## GUI API permission name mapping | GUI setting | API setting | |------------|------------| | Manager | organizer | | Content manager | fileOrganizer | | Contributor | writer | | Commenter | commenter | | Viewer | reader | ## Display Shared Drive themes ``` gam show teamdrivethemes ``` ## Manage Shared Drives ## Create a Shared Drive The user that creates a Shared Drive is given the permission role organizer for the Shared Drive, ``` gam [] create teamdrive [(theme|themeid )| ([customtheme ] [color ])] ( )* [hide ] [ou|org|orgunit ] [errorretries ] [updateinitialdelay ] [updateretrydelay ] [(csv [todrive *] (addcsvdata )*) | returnidonly] [adminaccess|asadmin] ``` * `themeid` - a Shared Drive themeId obtained from `show teamdrivethemes` * `customtheme` - set the backgroundImageFile property described here: https://developers.google.com/drive/v3/reference/teamdrives * `` - X coordinate, typically 0.0 * `` - Y coordinate, typically 0.0 * `` - width, typically 1.0 * `color` - set the Shared Drive color * ` ` - Set Shared Drive Restrictions * `hide ` - Set Shared Drive visibility If any attributes other than `themeid` are specified, GAM must create the Drive and then update the Drive attributes. Even though the Create API returns success, the Update API fails and reports that the Drive does not exist. * `errorretries ` - Number of create/update error retries; default value 5, range 0-10 * `updateinitialdelay ` - Initial delay after create before update: default value 10, range 0-60 * `updateretrydelay ` - Retry delay when update fails; default value 10, range 0-60 For this reason, GAM waits `updateinitialdelay ` seconds after the create before attempting the update. GAM repeats the update `errorretries ` times waiting `updateretrydelay ` between tries if the Update API continues to fail. This is acceptable when creating a single Shared Drive, for bulk Shared Drive creation see [Bulk Create Shared Drives](#bulk-create-shared-drives). This option is only available when the command is run as an administrator. * `ou|org|orgunit ` - See: https://workspaceupdates.googleblog.com/2022/05/shared-drives-in-organizational-units-open-beta.html By default, the Google Administrator and Shared Drive name and ID values are displayed on stdout. * `csv [todrive *]` - Write Google Administrator, Shared Drive name and ID values to a CSV file. * `addcsvdata ` - Add additional columns of data from the command line to the output * `returnidonly` - Display just the ID of the created Shared Drive as output When either of these options is chosen, no infomation about Shared Drive restrictions or hiding will be displayed. To retrieve the Shared Drive ID with `returnidonly`: ``` Linux/MacOS teamDriveId=$(gam create teamdrive ... returnidonly) Windows PowerShell $teamDriveId = & gam create teamdrive ... returnidonly ``` ## Bulk Create Shared Drives Most Shared Drive attributes can't be applied as part of the create, the Drive must be created and then updated with the desired attributes. As a newly created Drive can't be updated for 30+ seconds; split the operation into two commands: create and update. Make a CSV file SharedDriveNames.csv with at least one column, name. ``` gam redirect csv ./SharedDrivesCreated.csv multiprocess csv SharedDriveNames.csv gam create teamdrive "~name" csv ``` This will create a three column CSV file SharedDrivesCreated.csv with columns: User,name,id * There will be a row for each Shared Drive. * User will be the Google Administrator. Use the SharedDrivesCreated.csv file to apply the desired options/attributes. ``` gam redirect stdout ./SharedDrivesUpdated.txt multiprocess redirect stderr stdout csv ./SharedDrivesCreated.csv gam update shareddrive "~id" [options/attributes as desired] ``` Make Shared Drives for students ``` StudentSharedDrives.csv primaryEmail,Name bob@domain.com,Bob Jones mary@domain.com,Mary Smith ... # Create the student Shared Drives gam redirect stdout ./StudentSharedDrivesCreated.txt multiprocess redirect stderr stdout redirect csv ./StudentSharedDrivesCreated.csv multiprocess csv StudentSharedDrives.csv gam create shareddrive "~Name" csv addcsvdata primaryEmail "~primaryEmail" # Update attributes/options gam redirect stdout ./StudentSharedDrivesUpdated.txt multiprocess redirect stderr stdout csv ./StudentSharedDrivesCreated.csv gam update shareddrive "~id" [options/attributes as desired] # Add ACLs granting the students organizer access to their Shared Drives. gam redirect stdout ./StudentSharedDrivesAccess.txt multiprocess redirect stderr stdout csv StudentSharedDrivesCreated.csv gam add drivefileacl "~id" user "~primaryEmail" role organizer ``` ## Update Shared Drive settings These commands are used to set basic Shared Drive settings. ``` gam [] update teamdrive [name ] [adminaccess|asadmin] [(theme|themeid )| ([customtheme ] [color ])] ( )* [hide|hidden ] [ou|org|orgunit ] ``` * `themeid` - a Shared Drive themeId obtained from `show teamdrivethemes` * `customtheme` - set the backgroundImageFile property described here: https://developers.google.com/drive/v3/reference/teamdrives * `color` - set the Shared Drive color * ` ` - Set Shared Drive Restrictions * `hidden ` - Set Shared Drive visibility * `ou|org|orgunit ` - See: https://workspaceupdates.googleblog.com/2022/05/shared-drives-in-organizational-units-open-beta.html This option is only available when the command is run as an administrator. ## Delete a Shared Drive ``` gam [] delete teamdrive [adminaccess|asadmin] [allowitemdeletion] ``` By default, deleting a Shared Drive that contains any files/folders will fail. The `allowitemdeletion` option allows a Super Admin to delete a non-empty Shared Drive. This is not reversible, proceed with caution. ## Change Shared Drive visibility ``` gam [] hide teamdrive gam [] unhide teamdrive ``` ## Display Shared Drives These commands are used to get information about Shared Drives themselves, not the files/folders on the Shared Drives. ``` gam [] info teamdrive [adminaccess|asadmin] [fields ] [formatjson] gam [] show teamdriveinfo [adminaccess|asadmin] [fields ] [formatjson] ``` By default, Gam displays the information as an indented list of keys and values. * `formatjson` - Display the fields in JSON format. ``` gam [] show teamdrives [adminaccess|asadmin] [teamdriveadminquery|query ] [matchname ] [orgunit|org|ou ] [fields ] [formatjson] ``` By default, all Shared Drives are displayed; use the following options to select a subset of Shared Drives: * `teamdriveadminquery|query ` - Use a query to select Shared Drives * `matchname ` - Retrieve Shared Drives with names that match a pattern. * `orgunit|org|ou ` - Only Shared Drives in the specified Org Unit are selected By default, Gam displays the information as an indented list of keys and values. * `formatjson` - Display the fields in JSON format. ``` gam [] print teamdrives [todrive *] [adminaccess|asadmin] [teamdriveadminquery|query ] [matchname ] [orgunit|org|ou ] [fields ] [formatjson [quotechar ]] ``` By default, all Shared Drives are displayed; use the following options to select a subset of Shared Drives: * `teamdriveadminquery|query ` - Use a query to select Shared Drives * `matchname ` - Retrieve Shared Drives with names that match a pattern. * `orgunit|org|ou ` - Only Shared Drives in the specified Org Unit are selected By default, Gam displays the information as columns of fields; the following option causes the output to be in JSON format, * `formatjson` - Display the fields in JSON format. By default, when writing CSV files, Gam uses a quote character of double quote `"`. The quote character is used to enclose columns that contain the quote character itself, the column delimiter (comma by default) and new-line characters. Any quote characters within the column are doubled. When using the `formatjson` option, double quotes are used extensively in the data resulting in hard to read/process output. The `quotechar ` option allows you to choose an alternate quote character, single quote for instance, that makes for readable/processable output. `quotechar` defaults to `gam.cfg/csv_output_quote_char`. When uploading CSV files to Google, double quote `"` should be used. ### Examples Print information about all Shared Drives in the organization. ``` gam print teamdrives gam user admin@domain.com print teamdrives adminaccess ``` Print information about Shared Drives that have admin@domain.com as a member. ``` gam user admin@domain.com print teamdrives ``` ## Display all Shared Drives with no members ``` gam print teamdrives query "memberCount = 0" ``` ## Display all Shared Drives with no organizers ``` gam print teamdrives query "organizerCount = 0" ``` ## Display all Shared Drives with a specific organizer Substitute actual email address for `organizer@domain.com`. ``` gam config csv_output_header_filter "id,name" print teamdriveacls pm emailaddress organizer@domain.com role organizer em pma process pmselect ``` ## Display all Shared Drives without a specific organizer Substitute actual email address for `organizer@domain.com`. ``` gam config csv_output_header_filter "id,name" print teamdriveacls pm emailaddress organizer@domain.com role organizer em pma skip pmselect ``` ## Display List of Shared Drives in an Organizational Unit other than / Get the orgUnitID of OU / and use it (without the id:) in the print|show command. Adjust fields as desired. ``` gam info ou / nousers gam show teamdrives query "orgUnitId!='00gjdgxs2p9cxyz'" fields id,name,orgunit,createdtime gam print teamdrives query "orgUnitId!='00gjdgxs2p9cxyz'" fields id,name,orgunit,createdtime ``` ## Display List of Shared Drives in an Organizational Unit Get the orgUnitID of the desired OU and use it (without the id:) in the print|show command. Adjust fields as desired. ``` gam info ou nousers gam show teamdrives query "orgUnitId='03ph8a2z21rexy'" fields id,name,orgunit,createdtime gam print teamdrives query "orgUnitId='03ph8a2z21rexy'" fields id,name,orgunit,createdtime ``` Alternative method; `` defaults to `/`. ``` gam show oushareddrives [ou|org|orgunit ] [formatjson] gam print oushareddrives [todrive *] [ou|org|orgunit ] [formatjson [quotechar ]] ``` ## Manage Shared Drive access These commands are used to manage the ACLs on Shared Drives themselves, not the files/folders on the Shared Drives. ### Process single ACLs. ``` gam [] add drivefileacl anyone|(user )|(group )|(domain ) (role ) [withlink|(allowfilediscovery|discoverable [])] [expires|expiration