Function to add a teacher as a co-teacher to all classrooms of a given 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
}

Usage

Add-ClassroomTeacherToStudentsClasses -Student jbloggs -Teacher jsmith

AD Objects with the SamAccountName parameter can also be piped to this function

Get-ADGroupMember "Group Name" | Get-ADUser | Add-ClassroomTeacherToStudentsClasses -Teacher jsmith
Categories: GAMGSuitePowershell

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.