Remove student from all classrooms upon withdrawl

203 views
Skip to first unread message

Jay Strumwasser

unread,
Feb 26, 2019, 8:48:13 AM2/26/19
to GAM for G Suite
Good morning,

I am using the following pshell script to remove students from our school and place them in an org unit of suspended users

$user=Read-Host -Prompt "What is the user?"

$susstudent= "gam update user $user suspended on org '/Suspended/Student Suspended' gal off"

Write-Output "Suspending "$user"..."

Invoke-Expression $susstudent

Write-Output "Succesfully suspended "$user"!"


I want to also add the ability to remove them from classroom with a prompt like:

$classroom=Read-Host -Prompt "Do you want to remove from classroom?"

ideally, I would like this to pull membership of all classes and remove them completely

I already do this with my staff accounts using the same logic


$delgroups = "gam user $user delete groups"
Write-Output "Deleting groups from "$user"..."
Invoke-Expression $delgroups
Write-Output "Successfully deleted groups from "$user"!"




Please let me know if this is possible?


+KimNilsson

unread,
Mar 4, 2019, 4:22:49 AM3/4/19
to GAM for G Suite
gam print courses student student@email > courses.csv

That should list all courses which contains that student.
Then use the courses.csv as source for the removal of each student.

gam csv courses.csv gam course ~id delete students student@email

Jay Strumwasser

unread,
Mar 4, 2019, 8:35:08 AM3/4/19
to google-ap...@googlegroups.com
No way to automate this process? 

Best,

Jay Strumwasser
Director of Technology T: (718) 327-1352 Ext 115  
M: (516)229-1929
E: jstrum...@challengecharterschools.org
W: www.challengecharterschools.org


                     
Challenge Preparatory Charter School                           710 Hartman Lane Far Rockaway, NY
Teach Me...Prepare Me...Challenge Me...
     

Book time with me here remotely or in person: calendly.com/jstrumwasser


   

--
You received this message because you are subscribed to a topic in the Google Groups "GAM for G Suite" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-apps-manager/3GNgP-9Qr7w/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-apps-man...@googlegroups.com.
To post to this group, send email to google-ap...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/6fd08c3c-2dd6-4909-8b9c-0f7067712a69%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Challenge Preparatory Charter School Corporate Office
710 Hartman Lane
Far Rockaway, NY 11691

This is a staff email account managed by Challenge Preparatory Charter School.  This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the sender.

+KimNilsson

unread,
Mar 4, 2019, 10:51:08 AM3/4/19
to GAM for G Suite
Well, yes, but you'll have to schedule the commands yourself.

One command to print all suspended students with their corresponding courses.
Then another to remove those students from their courses.

Jay Strumwasser

unread,
Mar 4, 2019, 11:03:41 AM3/4/19
to google-ap...@googlegroups.com
Great I'll try that. Thanks! 


Best,

Jay Strumwasser
Director of Technology T: (718) 327-1352 Ext 115  
M: (516)229-1929
E: jstrum...@challengecharterschools.org
W: www.challengecharterschools.org


                     
Challenge Preparatory Charter School                           710 Hartman Lane Far Rockaway, NY
Teach Me...Prepare Me...Challenge Me...
     

Book time with me here remotely or in person: calendly.com/jstrumwasser


   
--
You received this message because you are subscribed to a topic in the Google Groups "GAM for G Suite" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-apps-manager/3GNgP-9Qr7w/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-apps-man...@googlegroups.com.
To post to this group, send email to google-ap...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.

For more options, visit https://groups.google.com/d/optout.

+KimNilsson

unread,
Mar 4, 2019, 11:22:55 AM3/4/19
to GAM for G Suite
If you have all your suspended students here '/Suspended/Student Suspended' you can use that to source all your students.

Maybe like this.

gamx ou '/Suspended/Student Suspended' print courses > courses.csv

hmmm, no, that will not work.
Also, that print doesn't contain the email address of the corresponding student and course.
You need the student's email address on the same line as the CourseID, else you can't do it as easily as I suggested with the second command.

On the other hand.
Something like this will print the courses.

gamx ou '/Suspended/Student Suspended' print users | gamx csv - fields Email gam print courses student ~Email > courses.csv

But, I don't know if that is a compound of all students' courses or only one of the students' courses. You may need to add some multi-process logic here.

Also, you're still missing the vital student email address for each line.

Jay Strumwasser

unread,
Mar 4, 2019, 12:12:36 PM3/4/19
to google-ap...@googlegroups.com
Thank you I will try some of these tricks! 


Best,

Jay Strumwasser
Director of Technology T: (718) 327-1352 Ext 115  
M: (516)229-1929
E: jstrum...@challengecharterschools.org
W: www.challengecharterschools.org


                     
Challenge Preparatory Charter School                           710 Hartman Lane Far Rockaway, NY
Teach Me...Prepare Me...Challenge Me...
     

Book time with me here remotely or in person: calendly.com/jstrumwasser


   
--
You received this message because you are subscribed to a topic in the Google Groups "GAM for G Suite" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-apps-manager/3GNgP-9Qr7w/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-apps-man...@googlegroups.com.
To post to this group, send email to google-ap...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages