Google G:SuiteInner GeekTechnologies for LearningUncategorizedWeb Design

Batch Script that will list ALL your Google Classrooms in your G:Suite deployment

In a larger deployment of Google G:Suite for Education my previous script for listing all the classrooms fails – it runs out of time.  I’ve now resolved this using script properties and batching the script so that it saves where it gets to before it times out and then schedules it’s self to run again using a timing trigger.

The amended script will now run over a period of time and will correctly list all the Google Classrooms in your G:Suite deployment. This took about one hour to list the 4727 classrooms in one G:Suite deployment I have access to.

When the script completes it sends an email to your email address – you’ll need to type this email address into the script!

This script will make a Sheet in your Drive with the filename of the current date and  “Class Listing” e.g. 20170516ClassroomListing, which will contain a list of all the Classrooms you have permission to view (superadmins can view all of them).  Don’t run it too close to midnight as the Sheet filename will change after 0:00 😉

You’ll need to use Google AppsScript, add this code and enable the Drive, AdminDirectory, Gmail and Classroom APIs for AppScript (from Resources->Advanced Google services…)

The Function listClasses is the one you want the script to run when you initially call it. After that it will schedule itself until it completes.

  1. John Ewens

    Thanks Charlie. I want to try and run the batch function but I get the following error:
    Invalid email: YourEmailAddress (line 231, file “Code”).
    I cant see where I enter the parmeters (my email) to prevent this.

  2. Mattias Bystedt

    Nice work!

    I have done some alterations in your code, mainly:
    – storing the results in an array and writing them “outside” the loop (this speeds things up considerably!)
    – no need to look up a user again if the script already has fetched the users name (then store these results on a second sheet)

    Now you can get about 4000- 5000 classrooms in about 5 minutes (instead of an hour):


  3. Matt Colwell

    Thanks for the updated script for larger deployments.. I get an error when I run it..

    Range not found, line 200

    Line 200 is ownerSheet.getRange(ownerRange).setValues(ownerArray);

  4. Cato

    Hi. Thanks for your script.

    I ran the script (listClasses) from I got this error – Range not found (line 200, file “Code”)

    And, I found Drive, Gmail and Classroom APIs, but no AdminDirectory. Is it cause the above error?

    Thanks again

  5. James Thom

    Any resolution on the following error?

    Range not found (line 200, file “Code”)

    200 ownerSheet.getRange(ownerRange).setValues(ownerArray);

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.