Skip to main content

Bulk creating Google Groups and Calendars in Google Apps and populating them with users for free

Suppose you want to make loads of groups and calendars and populate them with users and don't want to spend any money on any tools to do it. Well you can use GAM and a couple of scripts to do this. In a school you might want a Google Group and Calendar for each teaching group. You can achieve this using paid for tools such as Hapara's TeacherDashboard and tools that sync your MIS to AD and then to Google Apps - but these cost money and in the second case assume you actually have active directory.
So this is how to do it without any of those tools and zero cost.

Creating Groups

You will need a csv file with a list of group names first - classes names perhaps. Save the csv file to your GAM directory. Run the following command:

gam csv groups.csv gam create group ~groups

groups.csv = your csv file, the 'groups' in ~groups = the name of the column of groups in the csv file.

Populate with group owners

You might want teachers to be group owners. So to add them to the groups you will need a csv file with the email address of the teacher next to the classes they teach - so two columns. Each teacher could have multiple rows if they teach many classes. Run the following command:

gam csv teachers.csv gam update group ~group add owner user ~teacher

Again the ~group/teacher refer to the column heading on the csv file.

Populate with members

Students you might want to add as members. So you need a csv file with the email address of all the students next to the classes they take (the group email address - groupname@domainname). Run the following command:

gam csv students.csv gam update group ~group add member user ~students

Thats it for groups. Note, for the students where there are likely to be 1000's of lines, it can take a while to run!

Create Calendars

There is not a GAM command to create regular calendars, so you need to use a script. To make calendars, add the following script to a Google Sheet:
Create all those calendars:
function createcalendars() {
 var sheet = SpreadsheetApp.getActiveSheet();
 var data = sheet.getDataRange().getValues();
 for (var i = 0; i < data.length; i++) {
   Logger.log(data[i][0]);
 }
 for (var  i = 0; i < data.length; i++) {
   var calendar = CalendarApp.createCalendar(data[i][0]);
   Logger.log('Created the calendar "%s", with the ID "%s".',
    calendar.getName(), calendar.getId());
 }
}

This will read a list of calendar names from the Google Sheet and create them (good idea to do this on one central calendar owner user!) . So use the same name as you used for the group. You can use GAM to populate the calendars, but you first need the calendar email address. You can add this script to another sheet to list all the calendars.
function listCals() {
var calendars = CalendarApp.getAllOwnedCalendars();
data = []
for (var i = 0; i < calendars.length; i++) {
data.push([ calendars[i].getId(), calendars[i].getName()])
}
var destinationRange = SpreadsheetApp.getActiveSheet().getRange(1, 1, data.length, data[0].length);
destinationRange.setValues(data);
};

function onOpen() {
var sheet = SpreadsheetApp.getActiveSpreadsheet();
var entries = [{
name : "List Owned Calendars",
functionName : "listCals"
},];
sheet.addMenu("Calendar", entries);
}

Populate Calendars 

You will need a csv file with a list of your calendar owners (teachers) and the calendars they own (you will need to match calendar email address to the group). Run the following command:

gam csv teachcal.csv gam calendar ~calendar add editor ~teacher

for students -

gam csv studentcal.csv gam calendar ~calendar add read ~student

Where ~ goes before the name of the heading of the appropriate column in the CSV file.

Automating the process

You could put all of these GAM commands into a windows batch file (*.bat) and run it as a scheduled task overnight once a week to update groups as long as you can update the csv files. 

Popular posts from this blog

Delete a specific email using GAM

If a user send an inappropriate email to a loads of people or get stung by some sort of email exploit you can quickly delete the email from all of the recipients using a GAM command.
Step 1 - get the email header Go into Google Vault and search for the offending user or someone known to have got the message.
Click show details and grab the email ID. This will be a long string of characters followed by @mail.gmail.com
Step 2 - find out who has the email Go into Google Vault and find the original message sent by the offending user. Look at the details to see who got it. Copy the list and dump it into a spreadsheet. Clean up to just a list of emails with a column header 'mail'. Save as a csv file.
Step 3 - delete messages with GAM Put your CSV file in your GAM folder - this e.g. assumes its called mail.csv
Run:
gam csv mail.csv gam user ~mail delete messages query rfc822msgid:MESSAGEIDHERE doit

The alternative nuke option is:
gam all users delete messages query rfc822msgid:MESSAGEI…

How to push bookmarks to users in Chrome via the management console

With the release of Chrome and ChomeOS 37 an update to the management console has arrived that allows you to push bookmarks to users.

Under Device Management > Chrome > User Settings > User Experience you will now find the option to add managed bookmarks.


In the example above, the bookmarks are applied to the sub-OU of 'students' - so all our students will get these bookmarks. Simply add your url and the bookmark name, click the + and save. These will appear in a folder called 'yourdomain bookmarks' - see below:



Be aware that to get these bookmarks applied on a Windows/OS-X device the user must be signed into Chrome. Update: if you install the latest group policy template you can push the bookmarks via policy on PCs - details are given here.
Video Guide:

Using Quarantine Manager in Google Apps

Fairly recently Quarantine Manager was introduced to Google Apps. This is a tool that works alongside SPAM filtering, objectionable content and content compliance rules you may have setup. Essentially the Quarantine Manager holds messages that fall into the categories you have defined for administrators to view before approving or rejecting the messages.

We have used this to block all SPAM messages going to students. This is a brief look at how to set it up.  Please note, it is very important to have authenticated email setup - this prevents things like group notifications every ending up in SPAM.
Step 1 - define some Quarantine Names Head to email settings. You will find 'Manage Quarantines' below 'Authenticated email' near the bottom:
Click on 'ADD' - top left Give the quarantine a name and description of what it is going to do. Decide if you just want to drop the message or send a rejection email. See example below: This in itself does nothing - you have to …