I used to use the Teams PowerShell module but something has gone wrong with the edu template.
I therefore I'm trying to use the graph skd instead.
The following seems to make a class team no problem
$x = New-MgEducationClass `
-DisplayName "Barry" `
-MailNickname "Teams-Barry" `
-Description "Teams-Barry"
I then add a user:
$params = @{
"@odata.id" = "https://graph.microsoft.com/v1.0/education/users/$($user.Id)"
}
New-MgEducationClassTeacherByRef -EducationClassId $x.Id -BodyParameter $params
The docs suggest a teacher might also need to be a member, so I have experimented adding this step and also skipping it.
$params = @{
"@odata.id" = "https://graph.microsoft.com/v1.0/education/users/$($user.Id)"
}
New-MgEducationClassMemberByRef -EducationClassId $x.Id -BodyParameter $params
This seems to have worked when I check the graph:
Get-MgEducationUserTaughtClass -EducationUserId $user.Id
But not when I check in the Teams UI or the Teams PowerShell module:
Get-Team -User "some.email@domain.com"
Alternative method using the Marc LaFleur linked example. I couldn't get this to work from with application permissions.
Connect-MgGraph -Scopes "Team.Create" -NoWelcome
$params = @{
"template@odata.bind" = "https://graph.microsoft.com/v1.0/teamsTemplates('educationClass')"
displayName = "My Sample Team"
description = "My sample team's description"
}
New-MgTeam -BodyParameter $params