Creating classes using powershell 2020

%3CLINGO-SUB%20id%3D%22lingo-sub-1625628%22%20slang%3D%22en-US%22%3ECreating%20classes%20using%20powershell%202020%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1625628%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20using%20PowerShell%20to%20create%20classes%20in%20Teams%20and%20it%20works%20fine%20with%20the%20Microsoft%20Teams%20module%20version%200.9.6%2C%20which%20allow%20me%20to%20select%20the%20accurate%20template%20(EDU_Class).%20It's%20the%20only%20version%20that%20worked%20for%20me%20since%20the%20latest%20version%20doesn't%20allow%20you%20to%20define%20a%20template.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%2C%20to%20give%20you%20some%20context%2C%20I%20have%20to%20create%20multiple%20classes%20with%20multiple%20domains%20name%2C%20and%20this%20version%20doesn't%20allow%20you%20to%20specify%20the%20domain%20that%20you%20want%2C%20it%20uses%20the%20%22Alias%22%20parameter%2C%20example%20%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENew-Team%20-displayname%20%22MyClassName%22%20-Alias%20%22class2020%22%20-Template%20EDU_Class%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ethis%20command%20will%20create%20the%20class%20MyClassName%20with%20the%20following%20mail%20address%20%3A%20%3CA%20href%3D%22mailto%3Aclass2020%40domain.fr%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Eclass2020%40domainByDefault.fr%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20domain%20name%20is%20defined%20by%20default%20in%20the%20Microsoft%20tenant%20so%20you%20can%20only%20create%20classes%20for%201%20domain%20at%20a%20time%20but%20this%20is%20not%20the%20main%20problem%2C%20the%20main%20problem%20is%20that%20I%20have%20multiple%20classes%20who%20are%20supposed%20to%20be%20called%20%22class2020%22%20but%20with%20different%20domain%20name%2C%20for%20example%20%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22mailto%3Aclass20%40domain1.fr%2C%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Eclass20%40domain1.fr%2C%3C%2FA%3E%26nbsp%3B%3CA%20href%3D%22mailto%3Aclass20%40domain1.fr%2C%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Eclass20%40domain2.fr%2C%3C%2FA%3E%26nbsp%3B%3CA%20href%3D%22mailto%3Aclass20%40domain3.fr%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Eclass20%40domain3.fr%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%20when%20I%20try%20to%20create%20a%20team%20who%20has%20the%20same%20alias%20than%20another%20one%20(but%20with%20a%20different%20domain)%20it%20makes%20an%20error%20and%20it%20doesn't%20create%20the%20classes%20I%20want%20so%20I%20have%20to%20put%20something%20like%20%3A%20class20B%20to%20make%20it%20work%20and%20then%20I%20can%20change%20it%20manually%20through%20the%20Microsoft%20Administration%20platform%2C%20which%20is%20kind%20of%20annoying.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20there%20an%20other%20way%20to%20do%20this%20%3F%20will%20there%20be%20an%20update%20allowing%20us%20to%20use%20the%20-Template%20parameter%20in%20a%20future%20version%20of%20the%20Teams%20module%20%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECordially%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EGabrielF%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1625628%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EFeature%20Request%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPowerShell%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ETeams%20Education%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ETips%20%26amp%3B%20Tricks%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1626167%22%20slang%3D%22en-US%22%3ERe%3A%20Creating%20classes%20using%20powershell%202020%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1626167%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F764483%22%20target%3D%22_blank%22%3E%40Gab7%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOff%20the%20top%20of%20my%20head%20I%20am%20wondering%20if%20the%20way%20to%20go%20would%20be%20to%20facilitate%20the%20desired%20domain%20specification%20by%20way%20of%20creating%20an%20M365%20Group%2C%20along%20the%20lines%20of%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fanswers.microsoft.com%2Fen-us%2Fmsoffice%2Fforum%2Fmsoffice_o365admin-mso_domains%2Fcreate-an-office-365-group-in-different-domain%2F6272ad0b-8cb9-45ca-a96f-888a1b49f2e3%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fanswers.microsoft.com%2Fen-us%2Fmsoffice%2Fforum%2Fmsoffice_o365admin-mso_domains%2Fcreate-an-office-365-group-in-different-domain%2F6272ad0b-8cb9-45ca-a96f-888a1b49f2e3%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnd%20then%20once%20that%20is%20present%20and%20correct%20just%20Teams%20enable%20that%20Group.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20not%20sure%20it%20will%20solve%20your%20issue%20but%20worth%20knowing%20about%20anyway%2C%20I%20would%20also%20take%20a%20look%20at%3A%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fpnp.github.io%2Fcli-microsoft365%2Fcmd%2Fteams%2Fteam%2Fteam-add%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fpnp.github.io%2Fcli-microsoft365%2Fcmd%2Fteams%2Fteam%2Fteam-add%2F%3C%2FA%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3CP%3EI%20believe%20from%20an%20end%20user%20perspective%2C%20if%20they%20were%20creating%20Teams%20you%20would%20handle%20this%20by%20way%20of%20an%20Exchange%20Address%20Policy%2C%20so%20in%20theory%2C%20albeit%20excessive.%20You%20could%20look%20to%20have%20different%20accounts%2C%20with%20different%20EAPs%20applied%20based%20on%20which%20domain%20you%20want%20to%20create%20the%20Team%20in.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHenry%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1627114%22%20slang%3D%22en-US%22%3ERe%3A%20Creating%20classes%20using%20powershell%202020%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1627114%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F693840%22%20target%3D%22_blank%22%3E%40henryarphillips365%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20for%20your%20help%2C%20the%20thing%20is%20that%20I%20absolutely%20need%20the%20classroom%20template%20to%20create%20proper%20teams%2C%20but%20your%20first%20post%20gave%20me%20a%20great%20idea%2C%20it's%20a%20bit%20complex%20just%20to%20create%20a%20class%20but%20it%20might%20work.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20going%20to%20try%20to%20create%20the%20teams%20like%20I%20usually%20do%20but%20with%20a%20slight%20difference%20like%20I%20said%20%3A%3C%2FP%3E%3CP%3E%22%3CSPAN%3Eso%20I%20have%20to%20put%20something%20like%20%3A%20class20B%20to%20make%20it%20work%22%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3Eand%20then%20i'll%20use%20the%20%3A%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESet-UnifiedGroup%20-Identity%20%22class20B%40domain1.fr%22%20-PrimarySmtpAddress%20%22%3CA%20href%3D%22mailto%3Aclass20%40domain1.fr%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Eclass20%40domain1.fr%22%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eto%20change%20the%20address%20so%20I%20won't%20have%20to%20manually%20change%20the%20adresses%20in%20the%20administration%20web%20page.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20wonder%20if%20it%20will%20make%20an%20error%2C%20I'll%20keep%20this%20post%20updated.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20again.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EGabriel%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1627130%22%20slang%3D%22en-US%22%3ERe%3A%20Creating%20classes%20using%20powershell%202020%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1627130%22%20slang%3D%22en-US%22%3EHi%2C%3CBR%20%2F%3E%3CBR%20%2F%3EI%20think%20that%20will%20absolutely%20work.%20If%20the%20Exchange%20module%20doesn't%20play%20the%20SharePoint%20PnP%20Online%20module%20can%20do%20something%20similar%20but%20for%20permissions%20you%20may%20have%20to%20do%20something%20along%20the%20lines%20of%20connect-pnponline%20-scopes%20groups.readwrite.all%20or%20something%20to%20that%20effect.%3CBR%20%2F%3E%3CBR%20%2F%3EThanks%3CBR%20%2F%3E%3CBR%20%2F%3EHenry%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1627132%22%20slang%3D%22en-US%22%3ERe%3A%20Creating%20classes%20using%20powershell%202020%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1627132%22%20slang%3D%22en-US%22%3EAlso%20you%20may%20need%20to%20do%20a%20start-sleep%20in%20there%20after%20creation%20for%20x%20amount%20of%20seconds%20to%20allow%20for%20the%20group%20to%20be%20fully%20instantiated%20before%20moving%20on%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1641399%22%20slang%3D%22en-US%22%3ERe%3A%20Creating%20classes%20using%20powershell%202020%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1641399%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F693840%22%20target%3D%22_blank%22%3E%40henryarphillips365%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20worked%20!!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20now%20create%20my%20classes%20using%20the%20teams%20module%20but%20with%20a%20slight%20difference%20(like%20I%20said%20before)%20and%20when%20all%20teams%20are%20created%2C%20I%20use%20the%20given%20GroupID%20and%20the%20following%20command%20(with%20the%20exchange%20online%20module%20this%20time)%20%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESet-UnifiedGroup%20-Identity%20%24GroupID%20-PrimarySmtpAddress%20%24MailAfter%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnd%20it%20changes%20the%20primary%20address%20%3A)%3C%2Fimg%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ethx%20for%20your%20help%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Contributor

Hi,

 

I'm using PowerShell to create classes in Teams and it works fine with the Microsoft Teams module version 0.9.6, which allow me to select the accurate template (EDU_Class). It's the only version that worked for me since the latest version doesn't allow you to define a template.

 

So, to give you some context, I have to create multiple classes with multiple domains name, and this version doesn't allow you to specify the domain that you want, it uses the "Alias" parameter, example :

 

New-Team -displayname "MyClassName" -Alias "class2020" -Template EDU_Class

 

this command will create the class MyClassName with the following mail address : class2020@domainByDefault.fr

 

The domain name is defined by default in the Microsoft tenant so you can only create classes for 1 domain at a time but this is not the main problem, the main problem is that I have multiple classes who are supposed to be called "class2020" but with different domain name, for example :

 

class20@domain1.fr, class20@domain2.fr, class20@domain3.fr

 

So when I try to create a team who has the same alias than another one (but with a different domain) it makes an error and it doesn't create the classes I want so I have to put something like : class20B to make it work and then I can change it manually through the Microsoft Administration platform, which is kind of annoying.

 

Is there an other way to do this ? will there be an update allowing us to use the -Template parameter in a future version of the Teams module ?

 

Cordially,

 

GabrielF

 

5 Replies
Highlighted

Hi @Gab7 ,

 

Off the top of my head I am wondering if the way to go would be to facilitate the desired domain specification by way of creating an M365 Group, along the lines of https://answers.microsoft.com/en-us/msoffice/forum/msoffice_o365admin-mso_domains/create-an-office-3...

 

And then once that is present and correct just Teams enable that Group.

 

I am not sure it will solve your issue but worth knowing about anyway, I would also take a look at:
https://pnp.github.io/cli-microsoft365/cmd/teams/team/team-add/

I believe from an end user perspective, if they were creating Teams you would handle this by way of an Exchange Address Policy, so in theory, albeit excessive. You could look to have different accounts, with different EAPs applied based on which domain you want to create the Team in.

 

Thanks

 

Henry

Highlighted

@henryarphillips365

 

Thanks for your help, the thing is that I absolutely need the classroom template to create proper teams, but your first post gave me a great idea, it's a bit complex just to create a class but it might work.

 

I'm going to try to create the teams like I usually do but with a slight difference like I said :

"so I have to put something like : class20B to make it work"

 

and then i'll use the :

 

Set-UnifiedGroup -Identity "class20B@domain1.fr" -PrimarySmtpAddress "class20@domain1.fr"

 

to change the address so I won't have to manually change the adresses in the administration web page.

 

I wonder if it will make an error, I'll keep this post updated.

 

Thanks again.

 

Gabriel

 

Highlighted
Hi,

I think that will absolutely work. If the Exchange module doesn't play the SharePoint PnP Online module can do something similar but for permissions you may have to do something along the lines of connect-pnponline -scopes groups.readwrite.all or something to that effect.

Thanks

Henry
Highlighted
Also you may need to do a start-sleep in there after creation for x amount of seconds to allow for the group to be fully instantiated before moving on
Highlighted

@henryarphillips365 

 

It worked !!

 

I now create my classes using the teams module but with a slight difference (like I said before) and when all teams are created, I use the given GroupID and the following command (with the exchange online module this time) :

 

Set-UnifiedGroup -Identity $GroupID -PrimarySmtpAddress $MailAfter

 

And it changes the primary address :)

 

thx for your help