Google classroom_teachers group members

3,001 views
Skip to first unread message

Matt S

unread,
Oct 16, 2014, 10:56:25 AM10/16/14
to google-ap...@googlegroups.com
I titled this thread "Google classroom teachers_group members" as that is ultimately what I'm trying to do but my quest spans multiple GAM functions.  I'm trying to automate the process of adding teachers to the google-created classroom_teachers group for Google Classroom.

Our org structure is like this--

Root
--JR HI Users
----JR HI Students
--SR HI Users
----SR HI Students

Where teachers are in the respective "Users" groups and students are in the students group below.  We also have two groups called "jrhiteachers" and "srhiteachers" with the teachers of each school in them.  Users are added and removed and the membership of those groups are all handled by GADS.  I'm trying to figure out the best method to add new teachers to the classroom_teachers group.

My first idea was to export a list of users from each teacher group and them add them to the classroom_teachers group, most likely through command piping.  However, the command (gam print users query "orgUnitPath='/JR HI Users'") prints all users in that group and all subgroups.  I couldn't find any way to only list the users directly in that OU.

My next idea was to list the members of the two teacher groups that we have.  I see I can do a "gam info group group_name" but that also lists a lot of details along with the members so I would have to write a second parsing script to parse that output.  Is there a way to get a clean list of just members of a group?

My third idea was to use the group sync function.  I tested creating a test group and then running the command (gam update group test...@mydomain.com sync member org "/JR HI Users") and that worked beautifully by adding only the users directly in that OU.  Problem is my teachers are in a few different OUs so I don't see any way I can sync multiple OUs to a group.

Any insight would be appreciated.

Thanks,
Matt


Matt S

unread,
Oct 22, 2014, 2:17:48 PM10/22/14
to google-ap...@googlegroups.com
Bueller?

Kim Nilsson

unread,
Oct 29, 2014, 2:13:56 PM10/29/14
to google-ap...@googlegroups.com
I'm pretty sure you answered your own question there.
The sync feature would prohibit such a use.

I'm thinking you'd need instead to export the users from your separate OUs to a csv and then use that csv to populate the Classroom group.

Or just do some grep first and piping afterwards. List all users by ou and grep those you want.

echo member > personal.csv && gam print users ou | grep /personal | cut -d',' -f1 >> personal.csv

That will list all the teachers in my "personal" OU. In your case you may have to tell grep to only list the exact sub-OU you're looking for and not all that contain the same words.
Then some fancy cut to remove the unnecessary name of the OU, ",/personal" (in my example). The "echo" is to put the needed "member" headline in the csv for the 'gam csv' command.

You do that for each of your OUs. Do note that after the first run you should exclude the echo bit.

Then run that back through gam to add those emails to the Classroom group.

gam csv personal.csv gam update group classroom_teachers add member ~member

Works for me. :-)

Matt S

unread,
Oct 29, 2014, 4:30:22 PM10/29/14
to google-ap...@googlegroups.com
Well here is what I ended up with:

del output_all_users.csv
del output_teachers.csv

echo email
>output_teachers.csv
gam
print users ou >output_all_users.csv
for /F "tokens=1* delims=," %%A in (output_all_users.csv) do (
    echo
"%%A"|find /i "@" >nul
    IF NOT ERRORLEVEL
1 (
        echo
"%%B"|find /i "Users" >nul
        IF NOT ERRORLEVEL
1 (
            echo
"%%B"|find /i "Students" >nul
            IF ERRORLEVEL
1 (
                echo
Teacher: %%A
                echo
%%A>>output_teachers.csv
           
) ELSE (
               
echo Student: %%A
           
)
       
)
   
)
)
gam csv output_teachers
.csv gam update group classroom_teachers add member ~email


Reply all
Reply to author
Forward
0 new messages