-
Notifications
You must be signed in to change notification settings - Fork 473
GoogleDriveManagement
- Managing Google Drive Files and Folders for users
- Managing Google Drive Permissions for Users
- Add Resources Folder in My Drive for Users - EDU
GAM now supports Google Drive Management with the ability to add, update, view and delete Drive files and folders for users as well as adding, updating, viewing and deleting file and folder permissions.
gam user <username>|group <groupname>|ou <ouname>|all users show filelist [todrive] [query <query>] [allfields]
[createddate] [description] [fileextension] [filesize] [id] [restricted] [starred] [trashed] [viewed]
[lastmodifyingusername] [lastviewedbymedate] [modifieddate] [originalfilename] [quotaused] [shared] [writerscanshare]
Outputs a CSV file listing the Google Drive files/folders that the given user(s) own. By default, the output is sent to the screen and only the file owner, title and URL columns are shown. The optional todrive argument will upload the CSV data to a Google Docs Spreadsheet file in the Administrator's Google Drive rather than displaying it locally. The optional query argument allows the results to be narrowed to files/folders matching the given query. The query format is described in Google's documentation. The optional allfields arguments causes all possible columns to be included in the output. The optional createddate, description, fileextension, filesize, id, restricted, starred, trashed, viewed, lastmodifyingusername, lastviewedbymedate, modifieddate, originalfilename, quotaused, shared and writerscanshare arguments cause the given columns to be included in the output.
This example displays all of Joe Schmo's files
gam user [email protected] show filelist
This example displays all files for all users that contain the text "ProjectX". The results are uploaded to a Google spreadsheet for the admin user.
gam all users show filelist query "fullText contains 'ProjectX'" todrive
This example displays all PDF files that users under the Students OU own.
gam ou_and_children Students show filelist query "mimeType = 'application/pdf'"
gam user <username>|group <groupname>|ou <ouname>|all users add drivefile [localfile <filepath>]
[drivefilename <filename>] [convert] [ocr] [ocrlanguage <language>] [restricted] [starred] [trashed] [viewed]
[lastviewedbyme <date>] [modifieddate <date>] [description] [mimetype <type>] [parentid <folder id>]
[parentname <folder name>] [writerscantshare]
Create or upload a new file to Google Drive for the given user(s). By default, the command will create a new, empty file/folder. If the optional argument localfile is specified along with the full path to a document on the local computer, GAM will upload that file's contents to Drive. The optional argument drivefilename sets the name of the file/folder in Drive. The optional argument convert causes files to be converted into native Google Docs format where possible. The optional argument ocr causes OCR analysis of images and PDF files when they are converted to native Google Docs format. The optional argument ocrlanguage determines what language is used for ocr analysis. The optional argument restricted prevents users who have reader/commenter access to a file from downloading the file content. The optional arguments starred, trashed and viewed cause the respective action to take place on the new file. The optional arguments lastviewedbyme and modifieddate set the respective timestamps for the new file, the date should follow the format YYYY-MM-DDTHH:MM:SS.000Z. For example, 2013-04-20T12:33:47.166Z. The optional argument description gives a description for the new file. The optional argument mimetype forces the given MIME file type to be used for the new file. The optional argument parentid sets a parent folder for the uploaded/created file to show underneath. The optional argument parentname searches for the given folder name to put the file under. The optional argument writerscantshare prevents users who have writer/editor access to the file from adding additional permissions to the file (only owner can add permissions).
This example uploads the file sillycat.mp4 to Google Drive for a user
gam user [email protected] add drivefile localfile sillycat.mp4
This example creates a new folder called TPS Reports for all users and then creates a new, empty Google Doc, Spreadsheet, Presentation and Drawing under each user's folder.
gam all users add drivefile drivefilename "TPS Reports" mimetype gfolder
gam all users add drivefile drivefilename "TPS Doc" mimetype gdoc parentname 'TPS Reports'
gam all users add drivefile drivefilename "TPS Sheet" mimetype gsheet parentname 'TPS Reports'
gam all users add drivefile drivefilename "TPS Presentation" mimetype gpresentation parentname 'TPS Reports'
gam all users add drivefile drivefilename "TPS Drawing" mimetype gdrawing parentname 'TPS Reports'
This example uploads the MyRamblings.docx file to Google Drive and converts it to Google Doc native format. It also renames the file to a nicer looking "My Ramblings".
gam user [email protected] add drivefile localfile MyRamblings.docx convert drivefilename "My Ramblings"
gam user <username>|group <groupname>|ou <ouname>|all users update drivefile [id <drive file id> | drivefilename <filename>] [localfile <filename>] [newfilename <filename>] [convert] [ocr] [ocrlanguage <language>] [restricted true|false] [starred true|false] [trashed true|false] [viewed true|false] [lastviewedbyme <date>] [modifieddate <date>] [description <description>] [mimetype <MIME type>] [parentid <folder id>] [parentname <folder name>] [writerscantshare]
Update a Drive file's metadata and/or content. In order to determine which file(s) are updated, either the id or drivefilename arguments must be specified. id specifies the exact unique id of the file to be updated. drivefilename performs a search for files matching the given name. The optional argument localfile specifies a local file whose content will completely replace the content of the given drive file (file id, name, etc will remain unchanged). The optional arguments convert, ocr, ocrlanguage, restricted, starred, trashed, description, mimetype and viewed specify updates that should occur to a file's metadata. The optional lastviewedbyme and modifieddate arguments specify new timestamps that should be placed on the Drive file. The date should follow the format YYYY-MM-DDTHH:MM:SS.000Z. For example, 2013-04-20T12:33:47.166Z. The optional parentid and parentname arguments specify folders under which the drive file should be placed. The optional writerscantshare argument prevents file writers/editors from sharing the file with additional users.
This example updates the "My Ramblings" file to be starred and placed under a folder called "Brilliant things I've said" (assumes a folder by that name already exists for the user)
gam user [email protected] update drivefile drivefilename "My Ramblings" starred true parentname 'Brilliant things I've said'
This example updates the Drive file DailyReport.pdf with the contents of the local file Report-3-28-2014.pdf.
gam user [email protected] update drivefile drivefilename DailyReport.pdf localfile Report-3-28-2014.pdf
gam user <username>|group <groupname>|ou <ouname>|all users get drivefile [id <file id> | query <query>] [format <openoffice|microsoft|pdf>] [targetfolder <local path>]
Download the given Drive files to the local computer. Either the id or query parameters must be specified to determine which files should be downloaded. By default, Google Docs native format files are downloaded in openoffice format. The optional argument format allows you to download the files in Microsoft format (docx, xlsx, pptx, etc) or PDF format. The optional argument targetfolder allows you to specify where on the local computer the downloaded files should be placed.
Note that drive folder hierarchy is NOT maintained when downloading files with this command.
This example downloads the file with Drive ID adifd08 to the current path
gam user [email protected] get drivefile id adifd08
This example downloads all of a user's files to c:\jsmith-files using Microsoft Office format for downloading native Google Docs.
gam user [email protected] get drivefile query "'me' in owners" format microsoft
gam user <username>|group <groupname>|ou <ouname>|all users delete drivefile <file id> [purge]
Delete the given Drive files for user(s). The "file id" argument is the exact ID of a Google Drive file or a query to search the user's Drive for files in the format "query:<query>"
. By default, deleted folders are simply moved to the user's Trash folder which is purged after 30 days. The optional parameter purge causes the files to be immediately purged from the user's Google Drive so that they are no longer recoverable from Trash.
This example moves the given Drive file to the user's Trash in Drive.
gam user [email protected] delete drivefile 8sidfddosa
This example completely purges all files from a user's Drive that are PDFs (danger Will Robinson!!!)
gam user [email protected] delete drivefile "query:mimeType = 'application/pdf'" purge
gam user <email> show drivefileacl <file id>
shows the current permissions of a file or folder owned or shared with a given user.
This example shows the permissions of one of jsmith's files
gam user [email protected] show drivefileacl 0B8aCWH-xLi2NckxXOEp5REUtNEE
John Smith
domain: acme.org
emailAddress: [email protected]
photoLink: https://lh5.googleusercontent.com/-AzWvbYordY/AAAAAAAAAAE/AAAAAAAAERg/nzagv0IV4yQ/s64/photo.jpg
role: owner
type: user
id: 17297927562723854745
George Wilson
domain: gmail.com
emailAddress: [email protected]
photoLink: https://lh5.googleusercontent.com/-woxYfVbgI4w/AAAAAAAAAaI/AAAAAAAAb
SI/Y0RRW2LWX5U/s64/photo.jpg
role: writer
type: user
id: 00772439636938147216
gam user <user email> add drivefileacl <file id> [user|group|domain|anyone <value>] [withlink] [role <reader|commenter|writer|owner>] [sendemail] [emailmessage <message text>]
Grants a user, group, domain or anyone permission to the given Drive file/folder. The role parameter determines the level of access the given user(s) have to the file and can be one of reader, commenter, writer or owner. Specifying owner will change ownership of the file/folder and only works when the source and target accounts are in the same Google Apps instance. The optional withlink parameter specifies that the file is not "discoverable" or indexed. It is only available if the accessing user knows the exact URL. The optional sendemail parameter will send an email to the user(s) who have been granted access to the file (no email sent by default). The optional emailmessage parameter allows you to specify a portion of the email message body sent to the user.
This example silently gives Sally access to Tim's file
gam user [email protected] add drivefileacl 0B8aCWH-xLi2NckxXOEp5REUtNEE user [email protected] role writer withlink
This example gives the IT Google Group access to Tim's file and sends an email notification
gam user [email protected] add drivefileacl 0B8aCWH-xLi2NckxXOEp5REUtNEE group [email protected] role reader sendemail
This example gives anyone in the Acme organization access to Tim's file if they know the URL
gam user [email protected] add drivefileacl 0B8aCWH-xLi2NckxXOEp5REUtNEE domain acme.org role commenter withlink
This example gives anyone on the Internet (logged in to Google or not) access to Tim's file and makes it searchable/discoverable via Google.com search and other search engines
gam user [email protected] add drivefileacl 0B8aCWH-xLi2NckxXOEp5REUtNEE anyone role reader
gam user <user email> update drivefileacl <file id> <permission id> [withlink] [role <reader|commenter|writer|owner>] [transferownership <true|false>]
Changes a user or groups permissions to the given Drive file/folder. The permisson id parameter can be an email address or a numeric id as shown when listing a file's permissions. If an email address is used, GAM must first look up the permission id of that email address before updating (2 API calls instead of 1). If using numeric id, you must prefix it with "id:". The role parameter determines the level of access the given user(s) have to the file and can be one of reader, commenter, writer or owner. Specifying owner will change ownership of the file/folder and only works when the source and target accounts are in the same Google Apps instance. The optional withlink parameter specifies that the file is not "discoverable" or indexed. It is only available if the accessing user knows the exact URL. The optional transferownership parameter indicates whether changing a role to 'owner' downgrades the current owners to writers.
This example changes Sally from a reader to a writer for the file.
gam user [email protected] update drivefileacl 0B8aCWH-xLi2NckxXOEp5REUtNEE [email protected] role writer withlink
This example changes Sally from a reader to a writer for the file using her numeric permission ID.
gam user [email protected] update drivefileacl 0B8aCWH-xLi2NckxXOEp5REUtNEE id:65337053707119961365 role writer withlink
This example makes Sally the owner for the file and changes Tim from owner to writer for the file.
gam user [email protected] update drivefileacl 0B8aCWH-xLi2NckxXOEp5REUtNEE [email protected] role owner transferownership true
gam user <user email> delete drivefileacl <file id> <permission id>
Removes the give permission from the file. The permisson id parameter can be an email address or a numeric id as shown when listing a file's permissions. If an email address is used, GAM must first look up the permission id of that email address before updating (2 API calls instead of 1).
This example removes Sally's access to Tim's file
gam user [email protected] delete drivefileacl 0B8aCWH-xLi2NckxXOEp5REUtNEE [email protected]
#Add Resources Folder in My Drive for Users - EDU Adds a shared drive folder to a user's "My Drive" (root). This is helpful for EDU when administration would like to share Files, Docs, etc. in a central place for the user.
This example adds a shared folder to a user's My Drive.
gam user [email protected] update drivefile id 0B8aCWH-xLi2NckxXOEp5REUtNEE parentid root
Need more help? Ask on the GAM Discussion Group
Update History
Installation
- How to Install GAM7
- How to Upgrade GAMADV-XTD3 to GAM7
- How to Upgrade Legacy GAM to GAM7
- How to Update GAM7
- Install GAM as Python Library
- GAM7 on Chrome OS Devices
- GAM7 on Android Devices
- Google Network Addresses
- HTTPS Proxy
- SSL Root CA Certificates
- How to Uninstall GAM7
Configuration
- Authorization
- GAM Configuration
- Running GAM7 securely on a Google Compute Engine
- Using GAM7 with a delegated admin service account
- Using GAM7 with a YubiKey
Notes and Information
- Upgrade Benefits
- Questions? Visit the GAM Discussion Forum
- Scripts
- Other Resources
- Drive REST API v3
- BNF Syntax
- GAM Return Codes
- Python Regular Expressions
- Rclone
Definitions
Command Processing
- Bulk Processing
- Command Line Parsing
- Command Logging and Progress
- Command data from Google Docs/Sheets/Storage
- CSV Special Characters
- CSV Input Filtering
- CSV Output Filtering
- Meta Commands and File Redirection
- Permission matches
- Tag Replace
- Todrive
Collections
Client Access
- Addresses
- Administrators
- Alert Center
- Aliases
- Calendars
- Calendars - Access
- Calendars - Events
- Chrome Auto Update Expiration Counts
- Chrome Browser Cloud Management
- Chrome Device Needs Attention Counts
- Chrome Installed Apps
- Chrome Policies
- Chrome Printers
- Chrome Version Counts
- Chrome Version History
- ChromeOS Devices
- Classroom - Courses
- Classroom - Guardians
- Classroom - Invitations
- Classroom - Membership
- Cloud Channel
- Cloud Identity Devices
- Cloud Identity Groups
- Cloud Identity Groups - Membership
- Cloud Identity Policies
- Cloud Storage
- Context Aware Access Levels
- Customer
- Domains
- Domains - Verification
- Domain People - Contacts & Profiles
- Domain Shared Contacts - Global Address List
- Email Audit Monitor
- Find File Owner
- Google Data Transfers
- Groups
- Groups - Membership
- Inbound SSO
- Licenses
- Mobile Devices
- Organizational Units
- Reports
- Reseller
- Resources
- Send Email
- Schemas
- Shared Drives
- Sites
- Users
- Unmanaged Accounts
- Users - Signout and Turn off 2-Step Verification
- Vault - Takeout
- Version and Help
Special Service Account Access
Service Account Access
- Users - Analytics Admin
- Users - Application Specific Passwords
- Users - Backup Verification Codes
- Users - Calendars
- Users - Calendars - Access
- Users - Calendars - Events
- Users - Chat
- Users - Classification Labels
- Users - Classroom - Profile
- Users - Deprovision
- Users - Contacts
- Users - Contacts - Delegates
- Users - Drive - File Selection
- Users - Drive - Activity/Settings
- Users - Drive - Cleanup
- Users - Drive - Comments
- Users - Drive - Copy/Move
- Users - Drive - Files-Display
- Users - Drive - Files-Manage
- Users - Drive - Orphans
- Users - Drive - Ownership
- Users - Drive - Permissions
- Users - Drive - Query
- Users - Drive - Revisions
- Users - Drive - Shortcuts
- Users - Drive - Transfer
- Users - Forms
- Users - Gmail - Client Side Encryption
- Users - Gmail - Delegates
- Users - Gmail - Filters
- Users - Gmail - Forwarding
- Users - Gmail - Labels
- Users - Gmail - Messages/Threads
- Users - Gmail - Profile
- Users - Gmail - S/MIME
- Users - Gmail - SendAs/Signature/Vacation
- Users - Gmail - Settings
- Users - Group Membership
- Users - Keep
- Users - Looker Studio
- Users - Meet
- Users - Classroom - Profile
- Users - People - Contacts & Profiles
- Users - Photo
- Users - Profile Sharing
- Users - Shared Drives
- Users - Spreadsheets
- Users - Tasks
- Users - Tokens
- Users - YouTube
GAM Tutorials
- Managing Users, Groups, Aliases, Domains, Mobile and Chrome Devices, and Resource Calendars
- Group Settings
- Data Transfers
- Print Users, Groups, Aliases, Mobile and Chrome OS devices, OUs, Licenses and Reports
- Managing Custom User Schemas
- User Email Settings
- User Security Settings
- Managing Classroom
- Managing Devices
- Chrome Policy Settings
- Chrome Browser Management
- Calendar Settings
- Unmanaged Users and Invitations
- Google Drive Management
- Inbound SSO Settings
- Managing Admins
- Domain Verification
- Printers