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.
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.
In line 231 you need to delete YourEMailAddress and at email@example.com (your actual email address) – should run no problem after that.
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):
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);
Hi. Thanks for your script.
I ran the script (listClasses) from script.google.com. 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?
the line 200 code:
Any resolution on the following error?
Range not found (line 200, file “Code”)
It should be ok with the most recent code.
I love the script. Is it still possible to get the sheet as an email attachment?
Yes, I think you’d be able to use the Gmail API and add it as an attachment (depending on size).