Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save chris-bradbury/9194ccc50fd4fe6c99cc0a5eac3c2190 to your computer and use it in GitHub Desktop.
Save chris-bradbury/9194ccc50fd4fe6c99cc0a5eac3c2190 to your computer and use it in GitHub Desktop.
Powershell Function to add a teacher as a co-teacher to all Google Classrooms of a given student. Function accepts piped objects with $SamAccountName parameter as the student.
function Add-ClassroomTeacherToStudentsClasses {
[CmdletBinding()]
Param(
[string]
$Student,$Teacher,
[Parameter(ValueFromPipelineByPropertyName)]
$SamAccountName
)
$gamExeLocation = "\path\to\gam.exe"
##-- if no SamAccountName object was piped --##
if($null -eq $SamAccountName){
$SamAccountName = $student
}
. $gamExeLocation print courses student $SamAccountName state active | . $gamExeLocation csv - gam course ~id add teacher $Teacher
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment