Disabling the Google Chat Service for Some Students
The administration of a high school wants to disable the Google Chat service for some students.
A simple way to accomplish this would be to create a group named “no-chat” and set the Google Chat service to OFF for that group. However, in Google Workspace, services can only be set to ON for a group. It would be ideal if OFF could also be set, but that’s not currently possible.
Another option would be to create a new Organizational Unit (OU), set the service to OFF for that OU, and move the necessary users to it. While this approach works, it complicates the OU structure, which could become increasingly complex when future changes are required.
So, what is the best solution?
Set the Google Chat service to OFF for the “/student/HS” OU. Then, create a group named “HS-google-chat,” add all active high school users as members, and set the Google Chat service to ON for that group. Finally, remove the students for whom Google Chat should be disabled from the group.
This solution seems promising, but what happens when new students enroll in the high school or former students re-enroll? How can the “HS-google-chat” group remain up-to-date with all the students who should have Google Chat enabled?
The answer is to use GAM!
What I came up with is a 3-step process. The first step exports all the active users from the high school OU. The second step creates a new .csv file that removes any students that are listed in a nochat.csv file. The final step synchronizes the HS-google-chat group from the revised .csv file.
All of these steps are added to a Bash script and run as a cron job. Here is an example of the Bash script:
#! /bin/bash
export PATH=$PATH:/home/user/bin/gam7
export GAMCFGDIR="/home/user/GAMConfig"
# This exports all active users from the HS OU to a csv named HS_users.csv
gam redirect csv /home/user/GAMWork/HS_Chat/HS_users.csv print users query "orgUnitPath='/student/HS' isSuspended=false"
# This creates a new csv file named HS_chat_users.csv that is all the HS_users
# except users who are in the nochat.csv file
awk 'FNR==NR {a[$0];next} !($0 in a)' /home/user/GAMWork/HS_Chat/nochat.csv /home/user/GAMWork/HS_Chat/HS_users.csv > /home/user/GAMWork/HS_Chat/HS_chat_users.csv
# This syncs the HS_google_chat group with the users in the HS_chat_users.csv
# file
gam update group HS-google-chat sync members csvfile /home/user/GAMWork/HS_Chat/HS_chat_users.csv:primaryEmail
Currently, changing the users who should have Google Chat disabled requires manually editing the nochat.csv file. What I’d like to have it do is pull the list of students from a Google Sheet that is edited by the high school administration. That would give them control over which students don’t get Google Chat.