Reducing Google Workspace Storage Usage

These updates and timeline are written as of 2/17/21

Having information about users’ Google Workspace storage is helpful to determine how much storage each user is using, but there will be times you will need to be able to see more than analytics or even take action. At the time of this writing, there is no method to accomplish this within the Admin Console or in the Investigation tool.  If you are looking for how to gather users’ Google Workspace Storage usage, you can find our instructions in this guide.

Domain-Wide Delegation

After installing and authorizing GAM to work with your Google Workspace instance, In order to take action on Drive Files using GAM, first, you will need to ensure that Domain-Wide Delegation is enabled and configured.  Domain-Wide Delegation (DWD) allows an Administrator to create an authorization token as a user for the authorized scopes.  This can be checked by running the following command:

      gam user <email_address> check serviceaccount 

replacing the<email_address> with any regular user email account.  If DWD has been setup already, a list of scopes with PASS next to them will appear along with a note about the status:

      All scopes passed!

      Service account <client_id>  is fully authorized.

If DWD has not been configured, or a scope has not been authorized, you will see FAIL! next to the scopes that are not authorized and be provided with a link to the Admin Console to authorize your GAM app to use DWD.  Once it has been authorized within the Admin Console, it may take a few minutes to propagate, but re-running the command should eventually return a PASS next to each scope.

Using Reports Data

With Domain-Wide Delegation authorized you can now perform actions as your users, including listing and purging data from Google Drive. We recommend performing actions on a single user before moving to any Bulk Actions.  This helps you visualize what is happening and ensures that the command syntax is correct.

After you identify a user from your Reports Export which you are wanting to further explore, we will be performing the following tasks:

  • Display information about user’s files

  • Purge files from a user’s Google Drive

  • Perform actions in bulk

All of these actions are from the user’s perspective and deletion will not remove files from Google Vault so long as retention policies are in place for the respective services.

In all the following examples, to execute the commands you will need to replace < email_address > with the user’s primary email address.  To save the output of a command to a file, use < file_name_or_path_to_file > at the end of the command, replacing the < file_name_or_path_to_file > with the file you want to save it to.  To append the output to a file use < file_name_or_path_to_file >


Google Drive

Displaying a user’s files:

    gam user< email_address > print filelist name id fileextension filesize viewed modifieddate shared

Displaying a user’s file based on a query:

      gam user < email_address > print filelist query name id fileextension filesize viewed modifieddate shared 

The query format is described in Google’s documentation and should be wrapped in quotation marks.  For example the query to list all files that have a mimetype which includes images or videos would be: 

      “mimeType contains ‘video/’ or mimeType contains ‘image/'”

A list of the additional available parameters for this command can be found here.

Purging Files from a user’s Google Drive:

      gam user < email_address > delete drivefile purge

To purge a file from Drive, the file ID must be known.  This can be obtained from the previous command and appears in the “ID” column.  

Purging files can also be done using a query with the following command:

     gam user < email_address > delete drivefile “query:” purge

This command should be used with caution as it will permanently remove all files which match the query.

Bulk Actions

Up to this point, each action we have shown is for a single user or a single file.  In order to effectively use GAM, performing bulk actions are supported.  GAM can read through a CSV file, and perform a command for each line in the file.  

The syntax for performing a CSV based action is gam csv < path_to_file >   < gam_command > , however you will replace the parts of the command found in the CSV file with the header value from the file preceded with a ~ to tell GAM you’re using a variable.  It’s also important to note that the column header values are case sensitive.  If you happen to have a header that contains spaces (eg: Total storage usage) you can wrap the header value in quotation marks with the tilde (~) in front of the header: ~”Total storage usage” .

For example, to get all of the files for every user in your export file named “userlog.csv” and save it as a new file called “drive_storage_details.csv”, you could use the following command:

gam csv userlog.csv gam user ~User print filelist name id fileextension filesize viewed modifieddate shared >> drive_storage_details.csv

GAM would read through the file and run the command we previously compiled to list all of a user’s files for each row in the CSV, replacing ~User for the value in the column with the header “User”.  Once the command completes, a new CSV file is created with the concatenated output of each user’s Google Drive files with the requested columns.  

Depending on the number of users and the number of files for each user, the size of the output CSV from the above command can range from Megabytes to Gigabytes in size.  Adding in queries to limit the number of files listed for each user can be beneficial in reducing the noise in the output, because the next step is identifying which files to keep, and removing the line for each file from the drive_storage_details.csv file.

Once you have a list of files to purge from Google Drive, you can use the same gam csv syntax, but with the “files_to_delete.csv” file. This could be an edited copy of the drive_storage_details.csv file, or even the same file so long as changes are saved.  The command would look like this:

gam csv files_to_delete.csv gam user ~Owner delete drivefile ~id purge

Once the command completes, all the files in the spreadsheet will have been permanently deleted from users’ Google Drives.  The column headers “Owners” and “id” are taken from output of GAM’s drive file list command, and would only need to be changed if your source file used some other column headers.

Once you have generated the reports using the admin console and GAM, you can easily visualize your data in a simple Data Studio visualization. We created a quick template that you are free to copy and use that will connect directly to the two CSV files you create.  This visualization will help you determine the largest users as well as the largest files and even file types. You can download the template here ( This is a one time look but it will give you quick insight into current drive storage use.

If you still need help, engage Amplified IT’s support team to do it for you with our Google Workspace for Education Storage Insights Support Stack Engagement, which consumes 5 hours of direct support. We can provide a sortable list of file usage by user and file type, document total usage and top users, and assist with GAM commands to remediate any issues highlighted. Support contracts are also available as a part of the Google Service Offer (GSO); review our page to see if you qualify for the offer. Also, email if you are a current support customer and would like to commit a portion of your support contract to receiving storage insights. 


  • Stephen Gale
    Technical Support Analyst

  • About the Author:

    Stephen lives in Utah and enjoys the puzzle of investigating users’ problems and finding potential solutions. A recovering / reformed Gamer, Stephen throws himself into his passion for staying on top of all things Chrome OS and Chromebook related.  Prior to joining Amplified IT, Stephen served as a Network Admin in a Therapeutic Boarding School and an IT director, where he implemented G Suite for Education. Stephen has studied computer science and security at Weber State University, Western Governors University. A self-anointed honor, Stephen likes Chromebooks more than almost anyone else in the world.