Create Teams from csv

%3CLINGO-SUB%20id%3D%22lingo-sub-1243601%22%20slang%3D%22en-US%22%3ECreate%20Teams%20from%20csv%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1243601%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20trying%20to%20create%20Teams%20from%20a%20CSV%20file%3C%2FP%3E%3CP%3EMy%20Csv%3A%3C%2FP%3E%3CTABLE%20width%3D%22641%22%3E%3CTBODY%3E%3CTR%3E%3CTD%20width%3D%22116%22%3EMail%3C%2FTD%3E%3CTD%20width%3D%2279%22%3ETeamsName%3C%2FTD%3E%3CTD%20width%3D%22181%22%3ETeamsDescription%3C%2FTD%3E%3CTD%20width%3D%2268%22%3EType%3C%2FTD%3E%3CTD%20width%3D%2268%22%3ETypeTemplate%3C%2FTD%3E%3CTD%20width%3D%22129%22%3EOwners%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3EEV0123%3C%2FTD%3E%3CTD%3EEV%20-%20Prova%3C%2FTD%3E%3CTD%3EDescrizione1%3C%2FTD%3E%3CTD%3EPrivate%3C%2FTD%3E%3CTD%3EEDU_Class%3C%2FTD%3E%3CTD%3Eemail%40dom.it%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3ESN0123%3C%2FTD%3E%3CTD%3ESN%20-%20Prova2%3C%2FTD%3E%3CTD%3EDescrizione2%3C%2FTD%3E%3CTD%3EPrivate%3C%2FTD%3E%3CTD%3EEDU_Class%3C%2FTD%3E%3CTD%3Eemail%40dom.it%3C%2FTD%3E%3C%2FTR%3E%3C%2FTBODY%3E%3C%2FTABLE%3E%3CP%3EThis%20is%20the%20code%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3Efunction%20Create-NewTeam%0A%7B%20%20%20%0A%20%20%20param%20(%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%24ImportPath%0A%20%20%20%20%20%20%20%20%20)%20%20%20%0A%20%20Process%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20Import-Module%20MicrosoftTeams%0A%20%20%20%20%20%20%20%20%24cred%20%3D%20Get-Credential%0A%20%20%20%20%20%20%20%20%24username%20%3D%20%24cred.UserName%0A%20%20%20%20%20%20%20%20Connect-MicrosoftTeams%20-Credential%20%24cred%0A%20%20%20%20%20%20%20%20%24teams%20%3D%20Import-Csv%20-Path%20%24ImportPath%0A%20%20%20%20%20%20%20%20foreach(%24team%20in%20%24teams)%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%24getteam%3D%20get-team%20%7Cwhere-object%20%7B%20%24_.displayname%20-eq%20%24team.TeamsName%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20If(%24getteam%20-eq%20%24null)%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Write-Host%20%22Start%20creating%20the%20team%3A%20%22%20%24team.TeamsName%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%24group%20%3D%20New-Team%20-MailNickName%20%24team.Mail%20-displayname%20%24team.TeamsName%20-Description%20%24team.TeamsDescription%20-Visibility%20%24team.TeamType%20-Template%20%24team.TypeTemplate%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23Write-Host%20%22Adding%20team%20members...%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23Add-Users%20-Users%20%24team.Members%20-GroupId%20%24group.GroupId%20-CurrentUsername%20%24username%20%20-Role%20Member%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23Write-Host%20%22Adding%20team%20owners...%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23Add-Users%20-Users%20%24team.Owners%20-GroupId%20%24group.GroupId%20-CurrentUsername%20%24username%20%20-Role%20Owner%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Write-Host%20%22Completed%20creating%20the%20team%3A%20%22%20%24team.TeamsName%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%24team%3D%24null%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%7D%0A%20%20Create-NewTeam%20-ImportPath%20%22C%3A%5CUsers%5CPC%5COFFICE%20365%5CGruppi_class_team.csv%22%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%20class%3D%22contentCodeblock%22%3EThis%20is%20the%20error%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3ENew-Team%20%3A%20Impossibile%20convalidare%20l'argomento%20sul%20parametro%20'MailNickName'.%20L'argomento%20%C3%A8%20null%20o%20vuoto.%20Fornire%20un%0Aargomento%20che%20non%20sia%20null%20o%20vuoto%20ed%20eseguire%20di%20nuovo%20il%20comando.%0AIn%20riga%3A19%20car%3A49%0A%2B%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%24group%20%3D%20New-Team%20-MailNickName%20%24team.Mail%20-displayna%20...%0A%2B%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20~~~~~~~~~~%0A%20%20%20%20%2B%20CategoryInfo%20%20%20%20%20%20%20%20%20%20%3A%20InvalidData%3A%20(%3A)%20%5BNew-Team%5D%2C%20ParameterBindingValidationException%0A%20%20%20%20%2B%20FullyQualifiedErrorId%20%3A%20ParameterArgumentValidationError%2CMicrosoft.TeamsCmdlets.PowerShell.Custom.NewTeam%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1243601%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAdministrator%20Teams%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1332842%22%20slang%3D%22en-US%22%3ERe%3A%20Create%20Teams%20from%20csv%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1332842%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F28625%22%20target%3D%22_blank%22%3E%40Luca%20VALENTINO%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHi%20there%2C%20i%20had%20found%20a%20very%20similar%20script%20in%20another%20website.%3C%2FP%3E%3CP%3Ea%20guy%20called%20Andrew%20West%20had%20said%20in%20the%20comments%26nbsp%3B%20that%26nbsp%3B%20that%20the%20alias%26nbsp%3B%20and%20the%20AccessType%20should%20be%20changed.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIts%20in%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fwww.jijitechnologies.com%2Fblogs%2Fcreate-teams-microsoft-teams-powershell%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.jijitechnologies.com%2Fblogs%2Fcreate-teams-microsoft-teams-powershell%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDo%20let%20us%20know%20if%20your%20script%20works%20with%20those%20changes.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1347512%22%20slang%3D%22en-US%22%3ERe%3A%20Create%20Teams%20from%20csv%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1347512%22%20slang%3D%22en-US%22%3E%3CP%3E%26nbsp%3BI%20managed%20to%20create%20the%20class%20groups.%3CBR%20%2F%3ENow%20I%20want%20to%20insert%20the%20members%20in%20the%20various%20groups%20but%20nothing%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%23Connettere%20a%20Teams%0A%23Connect-MicrosoftTeams%0Afunction%20Add-Users%0A%7B%20%20%20%0A%20%20%20%20param(%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%24ImportPath%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%23%2C%24CurrentUsername%2C%24Role%0A%20%20%20%20%20%20%20%20%20%20)%20%20%20%0A%20%20%20%20Process%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20Import-Module%20MicrosoftTeams%0A%20%20%20%20%20%20%20%20%24cred%20%3D%20Get-Credential%0A%20%20%20%20%20%20%20%20%24username%20%3D%20%24cred.UserName%0A%20%20%20%20%20%20%20%20Connect-MicrosoftTeams%20-Credential%20%24cred%0A%20%20%20%20%20%20%20%20%23%24teamusers%20%3D%20Import-Csv%20-Path%20%24ImportPath%20%0A%20%20%20%20%20%20%20%20try%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%24teamusers%20%3D%20%24Users%20-split%20%22%3B%22%20%0A%20%20%20%20%20%20%20%20Write-Host%20%22Start%20add%20the%20users%3A%20%22%20%24Users%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if(%24teamusers)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20for(%24j%20%3D0%3B%20%24j%20-le%20(%24teamusers.count%20-%201)%20%3B%20%24j%2B%2B)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if(%24teamusers%5B%24j%5D%20-ne%20%24CurrentUsername)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Add-TeamUser%20-GroupId%20%24GroupName%20-User%20%24teamusers%5B%24j%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20Catch%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%7D%0A%7D%0AAdd-Users%20-ImportPath%20%22C%3A%5CPC%5COFFICE%20365%5CGruppi_membri_team.csv%22%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1436394%22%20slang%3D%22en-US%22%3ERe%3A%20Create%20Teams%20from%20csv%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1436394%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F634169%22%20target%3D%22_blank%22%3E%40EDU_ictGeek%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3EI%20tried%20the%20PowerShell%20Script%20method%20to%20add%20Bulk%20Team%20users.%20It%20worked%20%3A)%3C%2Fimg%3E%3C%2FP%3E%3CP%20class%3D%22%22%3E%3CA%20href%3D%22https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DCWgMKCbzisA%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20nofollow%22%3Ehttps%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DCWgMKCbzisA%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1930647%22%20slang%3D%22en-US%22%3ERe%3A%20Create%20Teams%20from%20csv%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1930647%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F634169%22%20target%3D%22_blank%22%3E%40EDU_ictGeek%3C%2FA%3E%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F28625%22%20target%3D%22_blank%22%3E%40Luca%20VALENTINO%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20successfully%20using%20the%20script%20from%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fblog.jijitechnologies.com%2Fcreate-teams-microsoft-teams-powershell%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3ECreate%20teams%20in%20Microsoft%20Teams%20through%20CSV%20using%20PowerShell%20%7C%20JiJi%20Technologies%3C%2FA%3E%26nbsp%3Bto%20create%20multiple%20teams%2C%20including%20the%20channels%20and%20adding%20members%20simultaneously%2C%20from%20a%20prepared%20CSV%20file.%3C%2FP%3E%3CP%3E%3CSTRONG%3EN.B.%3C%2FSTRONG%3E%20I%20made%20two%20small%20changes%20to%20the%20script.%3C%2FP%3E%3CUL%3E%3CLI%3EPreparation%3A%3CUL%3E%3CLI%3EI%20ran%20PowerShell%20in%20Admin%20mode%26nbsp%3B%3C%2FLI%3E%3CLI%3EI%20ensured%20that%20I%20had%20installed%20the%20current%20version%20of%20the%20MicrosoftTeams%20PowerShell%20module.%20I%20ran%20the%20following%20command%20in%20PowerShell%20(in%20admin%20mode)%26nbsp%3BInstall-Module%20-Name%20MicrosoftTeams%20-RequiredVersion%201.1.6%3C%2FLI%3E%3C%2FUL%3E%3C%2FLI%3E%3CLI%3EI%20made%20the%20two%20highlighted%20changes%20to%20script%20in%20the%20function%20%3CSTRONG%3ECreate-NewTeam%3C%2FSTRONG%3E%3A%26nbsp%3B%3CUL%3E%3CLI%3E%24group%20%3D%20New-Team%20-%3CFONT%20color%3D%22%23FF0000%22%3E%3CSTRONG%3EMailNickName%3C%2FSTRONG%3E%3C%2FFONT%3E%20%24team.TeamsName%20-displayname%20%24team.TeamsName%20-%3CFONT%20color%3D%22%23FF0000%22%3E%3CSTRONG%3ETemplate%3C%2FSTRONG%3E%3C%2FFONT%3E%20%24team.TeamType%3C%2FLI%3E%3CLI%3EIn%20the%20original%20script%20it%20uses%20-Alias%20instead%20of%20-MailNickName%20and%20-AccessType%20instead%20of%20-Template%3C%2FLI%3E%3C%2FUL%3E%3C%2FLI%3E%3CLI%3EMy%20CSV%20file%20had%20the%20following%20headers%20and%20example%20content%3CTABLE%20border%3D%220%22%20width%3D%22340%22%20cellspacing%3D%220%22%20cellpadding%3D%220%22%3E%3CTBODY%3E%3CTR%3E%3CTD%20width%3D%2297.5px%22%20height%3D%2230px%22%3ETeamsName%3C%2FTD%3E%3CTD%20width%3D%2281px%22%20height%3D%2230px%22%3ETeamType%3C%2FTD%3E%3CTD%20width%3D%22111px%22%20height%3D%2230px%22%3EChannelName%3C%2FTD%3E%3CTD%20width%3D%2264.5px%22%20height%3D%2230px%22%3EOwners%3C%2FTD%3E%3CTD%20width%3D%2278.5px%22%20height%3D%2230px%22%3EMembers%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%2297.5px%22%20height%3D%2230px%22%3E21Accounting11%3C%2FTD%3E%3CTD%20width%3D%2281px%22%20height%3D%2230px%22%3EEDU_class%3C%2FTD%3E%3CTD%20width%3D%22111px%22%20height%3D%2230px%22%3EChannel1%3B%20Channel2%3C%2FTD%3E%3CTD%20width%3D%2264.5px%22%20height%3D%2230px%22%3ETeacher1%40domain.com%3C%2FTD%3E%3CTD%20width%3D%2278.5px%22%20height%3D%2230px%22%3E%3CA%20href%3D%22mailto%3AMember1%40domain.com%3B%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EMember1%40domain.com%3B%3C%2FA%3E%26nbsp%3Bmember2%40domain.com%3C%2FTD%3E%3C%2FTR%3E%3C%2FTBODY%3E%3C%2FTABLE%3E%3C%2FLI%3E%3CLI%3EThe%20Team%20Type%20is%20important%20-%20you%20need%20that%20in%20an%20educational%20setting%20to%20create%20Class%20type%20teams.%3C%2FLI%3E%3C%2FUL%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2048563%22%20slang%3D%22en-US%22%3ERe%3A%20Create%20Teams%20from%20csv%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2048563%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F164657%22%20target%3D%22_blank%22%3E%40Marius%20Pretorius%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EGood%20afternoon%2C%20thank%20you%20for%20this%2C%20its%20really%20useful.%26nbsp%3B%20I%20will%20try%20to%20emulate%20to%20the%20letter.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20is%20very%20kind%2C%26nbsp%3B%20thanks%20again.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2271376%22%20slang%3D%22en-US%22%3ERe%3A%20Create%20Teams%20from%20csv%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2271376%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F164657%22%20target%3D%22_blank%22%3E%40Marius%20Pretorius%3C%2FA%3E%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F28625%22%20target%3D%22_blank%22%3E%40Luca%20VALENTINO%3C%2FA%3E%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F634169%22%20target%3D%22_blank%22%3E%40EDU_ictGeek%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EGood%20day!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20really%20need%20your%20help...%20please....%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20tried%20your%20codes%20but%20nothing%20happened....%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eattached%20is%20my%20.csv%20file%20for%20reference%20and%20below%20(here)%20is%20my%20code...%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Efunction%20Create-Channel%3CBR%20%2F%3E%7B%3CBR%20%2F%3Eparam%20(%3CBR%20%2F%3E%24ChannelName%2C%24GroupId%3CBR%20%2F%3E)%3CBR%20%2F%3EProcess%3CBR%20%2F%3E%7B%3CBR%20%2F%3Etry%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%24teamchannels%20%3D%20%24ChannelName%20-split%20%22%3B%22%3CBR%20%2F%3Eif(%24teamchannels)%3CBR%20%2F%3E%7B%3CBR%20%2F%3Efor(%24i%20%3D0%3B%20%24i%20-le%20(%24teamchannels.count%20-%201)%20%3B%20%24i%2B%2B)%3CBR%20%2F%3E%7B%3CBR%20%2F%3ENew-TeamChannel%20-GroupId%20%24GroupId%20-DisplayName%3C%2FP%3E%3CP%3E%24teamchannels%5B%24i%5D%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3CBR%20%2F%3ECatch%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3Efunction%20Add-Users%3CBR%20%2F%3E%7B%3CBR%20%2F%3Eparam(%3CBR%20%2F%3E%24Users%2C%24GroupId%2C%24CurrentUsername%2C%24Role%3CBR%20%2F%3E)%3CBR%20%2F%3EProcess%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%3CBR%20%2F%3Etry%7B%3CBR%20%2F%3E%24teamusers%20%3D%20%24Users%20-split%20%22%3B%22%3CBR%20%2F%3Eif(%24teamusers)%3CBR%20%2F%3E%7B%3CBR%20%2F%3Efor(%24j%20%3D0%3B%20%24j%20-le%20(%24teamusers.count%20-%201)%20%3B%20%24j%2B%2B)%3CBR%20%2F%3E%7B%3CBR%20%2F%3Eif(%24teamusers%5B%24j%5D%20-ne%20%24CurrentUsername)%3CBR%20%2F%3E%7B%3CBR%20%2F%3EAdd-TeamUser%20-GroupId%20%24GroupId%20-User%3C%2FP%3E%3CP%3E%24teamusers%5B%24j%5D%20-Role%20%24Role%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3CBR%20%2F%3ECatch%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3Efunction%20Create-NewTeam%3CBR%20%2F%3E%7B%3CBR%20%2F%3Eparam%20(%3CBR%20%2F%3E%24ImportPath%3CBR%20%2F%3E)%3CBR%20%2F%3EProcess%3CBR%20%2F%3E%7B%3CBR%20%2F%3EImport-Module%20MicrosoftTeams%3CBR%20%2F%3E%24cred%20%3D%20Get-Credential%3CBR%20%2F%3E%24username%20%3D%20%24cred.UserName%3CBR%20%2F%3EConnect-MicrosoftTeams%20-Credential%20%24cred%3CBR%20%2F%3E%24teams%20%3D%20Import-Csv%20-Path%20%24ImportPath%3CBR%20%2F%3Eforeach(%24team%20in%20%24teams)%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%24getteam%3D%20get-team%20%7Cwhere-object%20%7B%20%24_.displayname%20-eq%3C%2FP%3E%3CP%3E%24team.TeamsName%7D%3CBR%20%2F%3EIf(%24getteam%20-eq%20%24null)%3CBR%20%2F%3E%7B%3CBR%20%2F%3EWrite-Host%20%22Start%20creating%20the%20team%3A%20%22%20%24team.TeamsName%3CBR%20%2F%3E%24group%20%3D%20New-Team%20-DisplayName%20%24team.TeamsName%20-%3C%2FP%3E%3CP%3Edisplayname%20%24team.TeamsName%20-Template%20%24team.TeamType%3CBR%20%2F%3EWrite-Host%20%22Creating%20channels...%22%3CBR%20%2F%3ECreate-Channel%20-ChannelName%20%24team.ChannelName%20-GroupId%3C%2FP%3E%3CP%3E%24group.GroupId%3CBR%20%2F%3EWrite-Host%20%22Adding%20team%20members...%22%3CBR%20%2F%3EAdd-Users%20-Users%20%24team.Members%20-GroupId%20%24group.GroupId%20-%3C%2FP%3E%3CP%3ECurrentUsername%20%24username%20-Role%20Member%3CBR%20%2F%3EWrite-Host%20%22Adding%20team%20owners...%22%3CBR%20%2F%3EAdd-Users%20-Users%20%24team.Owners%20-GroupId%20%24group.GroupId%20-%3C%2FP%3E%3CP%3ECurrentUsername%20%24username%20-Role%20Owner%3CBR%20%2F%3EWrite-Host%20%22Completed%20creating%20the%20team%3A%20%22%3C%2FP%3E%3CP%3E%24team.TeamsName%3CBR%20%2F%3E%24team%3D%24null%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3ECreate-NewTeam%20-ImportPath%20%22C%3A%5CUsers%5CAdmin1234%5CDesktop%5C1.csv%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20very%20much.%20Best%20Regards.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2291969%22%20slang%3D%22en-US%22%3ERe%3A%20Create%20Teams%20from%20csv%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2291969%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1025361%22%20target%3D%22_blank%22%3E%40RicMercene%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPlease%20see%20my%20post%20%3CA%20title%3D%22Creating%20bulk%20class%20teams%20from%20a%20CSV%20file%22%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fmicrosoft-teams-for-education%2Fteams-admin-creating-bulk-class-teams-using-powershell-and-a-csv%2Fm-p%2F1931633%2Fhighlight%2Ftrue%23M589%22%20target%3D%22_self%22%3Ehere%20(Creating%20bulk%20class%20teams%20from%20a%20CSV%20file)%3C%2FA%3E.%20It%20has%20the%20PowerShell%20module%20as%20well%20as%20a%20sample%20CSV%20file.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2292294%22%20slang%3D%22en-US%22%3ERe%3A%20Create%20Teams%20from%20csv%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2292294%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1025361%22%20target%3D%22_blank%22%3E%40RicMercene%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20seems%20your%20code%20is%20missing%20a%20function%20name%20and%20opening%20curly%20bracket%20at%20the%20beginning%20and%20a%20closing%20curly%20bracket%20below%20your%20last%20line.%20Your%20code%20looks%20like%20this%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CBLOCKQUOTE%3E%3CHR%20%2F%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Efunction%20Create-Channel%3CBR%20%2F%3E%7B%3CBR%20%2F%3E.%3C%2FP%3E%3CP%3E.%3C%2FP%3E%3CP%3E.%3C%2FP%3E%3CP%3ECreate-NewTeam%20-ImportPath%20%22C%3A%5CUsers%5CAdmin1234%5CDesktop%5C1.csv%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CHR%20%2F%3E%3C%2FBLOCKQUOTE%3E%3CP%3EIt%20should%20read%20like%20this%3A%20(I'm%20only%20including%20the%20missing%20code)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3EFunction%20New-TeamsFromCSV%0A%7B%0Afunction%20Create-Channel%0A.%0A.%0A.%0ACreate-NewTeam%20-ImportPath%20%22C%3A%5CUsers%5CAdmin1234%5CDesktop%5C1.csv%22%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EObviously%2C%20you%20have%20to%20take%20a%20few%20steps%20for%20your%20code%20to%20execute%20in%20PowerShell%3A%3C%2FSPAN%3E%3C%2FP%3E%3CUL%3E%3CLI%3E%3CSPAN%3E%3CSPAN%3Eyou%20need%20to%20use%20the%20PowerShell%20command%20line%20to%20import%20the%20module%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FLI%3E%3C%2FUL%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3E%20import-module%20TheModuleName.psm1%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CUL%3E%3CLI%3E%26nbsp%3B%3CSPAN%3EI%20prefer%20to%20run%20PowerShell%20in%20Administrator%20mode%20to%20make%20sure%20I%20don't%20run%20into%20permissions%20problems%3C%2FSPAN%3E%3C%2FLI%3E%3CLI%3E%3CSPAN%3EThe%20name%20of%20the%20module%20you%20need%20to%20import%20is%20the%20(path%20and%20the%20)name%20of%20your%20.psm1%20file%3C%2FSPAN%3E%3C%2FLI%3E%3CLI%3E%3CSPAN%3Eand%20call%20the%20function%20(run%20it)%20as%20shown%20below.%3C%2FSPAN%3E%3C%2FLI%3E%3C%2FUL%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3ENew-TeamsFromCSV%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBecause%20you%20are%20connecting%20to%20Teams%20Admin%2C%20you%20will%20be%20asked%20for%20your%20credentials.%20You%20need%20to%20be%20a%20Teams%20Administrator%20and%20provide%20that%20username%2Femail%20address%20and%20password.%20Thereafter%20you%20will%20be%20flying!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2295707%22%20slang%3D%22en-US%22%3ERe%3A%20Create%20Teams%20from%20csv%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2295707%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F164657%22%20target%3D%22_blank%22%3E%40Marius%20Pretorius%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EGood%20day!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20for%20your%20response....%20I%20will%20definitely%20study%20and%20try%20your%20program%20and%20instruction...%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECheers!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBest%20Regards.%20%3A)%3C%2Fimg%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2295884%22%20slang%3D%22en-US%22%3ERe%3A%20Create%20Teams%20from%20csv%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2295884%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F164657%22%20target%3D%22_blank%22%3E%40Marius%20Pretorius%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EGood%20day!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20already%20tried%20your%20code%20but%20this%20is%20the%20error%20message%20i've%20received...%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22RicMercene_1-1619493966172.jpeg%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F275704iCC593629CC98CD21%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22RicMercene_1-1619493966172.jpeg%22%20alt%3D%22RicMercene_1-1619493966172.jpeg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ebelow%20is%20the%20whole%20code...%3C%2FP%3E%3CP%3E----%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFunction%20New-TeamsFromCSV%3CBR%20%2F%3E%7B%3CBR%20%2F%3Efunction%20Create-Channel%3CBR%20%2F%3E%7B%3CBR%20%2F%3Eparam%20(%3CBR%20%2F%3E%24ChannelName%2C%24GroupId%3CBR%20%2F%3E)%3CBR%20%2F%3EProcess%3CBR%20%2F%3E%7B%3CBR%20%2F%3Etry%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%24teamchannels%20%3D%20%24ChannelName%20-split%20%22%3B%22%3CBR%20%2F%3Eif(%24teamchannels)%3CBR%20%2F%3E%7B%3CBR%20%2F%3Efor(%24i%20%3D0%3B%20%24i%20-le%20(%24teamchannels.count%20-%201)%20%3B%20%24i%2B%2B)%3CBR%20%2F%3E%7B%3CBR%20%2F%3ENew-TeamChannel%20-GroupId%20%24GroupId%20-DisplayName%3C%2FP%3E%3CP%3E%24teamchannels%5B%24i%5D%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3CBR%20%2F%3ECatch%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3Efunction%20Add-Users%3CBR%20%2F%3E%7B%3CBR%20%2F%3Eparam(%3CBR%20%2F%3E%24Users%2C%24GroupId%2C%24CurrentUsername%2C%24Role%3CBR%20%2F%3E)%3CBR%20%2F%3EProcess%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%3CBR%20%2F%3Etry%7B%3CBR%20%2F%3E%24teamusers%20%3D%20%24Users%20-split%20%22%3B%22%3CBR%20%2F%3Eif(%24teamusers)%3CBR%20%2F%3E%7B%3CBR%20%2F%3Efor(%24j%20%3D0%3B%20%24j%20-le%20(%24teamusers.count%20-%201)%20%3B%20%24j%2B%2B)%3CBR%20%2F%3E%7B%3CBR%20%2F%3Eif(%24teamusers%5B%24j%5D%20-ne%20%24CurrentUsername)%3CBR%20%2F%3E%7B%3CBR%20%2F%3EAdd-TeamUser%20-GroupId%20%24GroupId%20-User%3C%2FP%3E%3CP%3E%24teamusers%5B%24j%5D%20-Role%20%24Role%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3CBR%20%2F%3ECatch%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3Efunction%20Create-NewTeam%3CBR%20%2F%3E%7B%3CBR%20%2F%3Eparam%20(%3CBR%20%2F%3E%24ImportPath%3CBR%20%2F%3E)%3CBR%20%2F%3EProcess%3CBR%20%2F%3E%7B%3CBR%20%2F%3EImport-Module%20MicrosoftTeams%3CBR%20%2F%3E%24cred%20%3D%20Get-Credential%3CBR%20%2F%3E%24username%20%3D%20%24cred.UserName%3CBR%20%2F%3EConnect-MicrosoftTeams%20-Credential%20%24cred%3CBR%20%2F%3E%24teams%20%3D%20Import-Csv%20-Path%20%24ImportPath%3CBR%20%2F%3Eforeach(%24team%20in%20%24teams)%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%24getteam%3D%20get-team%20%7Cwhere-object%20%7B%20%24_.displayname%20-eq%3C%2FP%3E%3CP%3E%24team.TeamsName%7D%3CBR%20%2F%3EIf(%24getteam%20-eq%20%24null)%3CBR%20%2F%3E%7B%3CBR%20%2F%3EWrite-Host%20%22Start%20creating%20the%20team%3A%20%22%20%24team.TeamsName%3CBR%20%2F%3E%24group%20%3D%20New-Team%20-DisplayName%20%24team.TeamsName%20-%3C%2FP%3E%3CP%3Edisplayname%20%24team.TeamsName%20-Template%20%24team.TeamType%3CBR%20%2F%3EWrite-Host%20%22Creating%20channels...%22%3CBR%20%2F%3ECreate-Channel%20-ChannelName%20%24team.ChannelName%20-GroupId%3C%2FP%3E%3CP%3E%24group.GroupId%3CBR%20%2F%3EWrite-Host%20%22Adding%20team%20members...%22%3CBR%20%2F%3EAdd-Users%20-Users%20%24team.Members%20-GroupId%20%24group.GroupId%20-%3C%2FP%3E%3CP%3ECurrentUsername%20%24username%20-Role%20Member%3CBR%20%2F%3EWrite-Host%20%22Adding%20team%20owners...%22%3CBR%20%2F%3EAdd-Users%20-Users%20%24team.Owners%20-GroupId%20%24group.GroupId%20-%3C%2FP%3E%3CP%3ECurrentUsername%20%24username%20-Role%20Owner%3CBR%20%2F%3EWrite-Host%20%22Completed%20creating%20the%20team%3A%20%22%3C%2FP%3E%3CP%3E%24team.TeamsName%3CBR%20%2F%3E%24team%3D%24null%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3ECreate-NewTeam%20-ImportPath%20%22C%3A%5CUsers%5CAdmin1234%5CDesktop%5CNewTeams%3C%2FP%3E%3CP%3E%5CNewTeams.csv%22%3C%2FP%3E%3CP%3E%7D%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

I am trying to create Teams from a CSV file

My Csv:

MailTeamsNameTeamsDescriptionTypeTypeTemplateOwners
EV0123EV - ProvaDescrizione1PrivateEDU_Classemail@dom.it
SN0123SN - Prova2Descrizione2PrivateEDU_Classemail@dom.it

This is the code:

 

 

 

 

 

function Create-NewTeam
{   
   param (   
             $ImportPath
         )   
  Process
    {
        Import-Module MicrosoftTeams
        $cred = Get-Credential
        $username = $cred.UserName
        Connect-MicrosoftTeams -Credential $cred
        $teams = Import-Csv -Path $ImportPath
        foreach($team in $teams)
        {
            $getteam= get-team |where-object { $_.displayname -eq $team.TeamsName}
            If($getteam -eq $null)
            {
                Write-Host "Start creating the team: " $team.TeamsName
                $group = New-Team -MailNickName $team.Mail -displayname $team.TeamsName -Description $team.TeamsDescription -Visibility $team.TeamType -Template $team.TypeTemplate
                #Write-Host "Adding team members..."
                #Add-Users -Users $team.Members -GroupId $group.GroupId -CurrentUsername $username  -Role Member 
                #Write-Host "Adding team owners..."
                #Add-Users -Users $team.Owners -GroupId $group.GroupId -CurrentUsername $username  -Role Owner
                Write-Host "Completed creating the team: " $team.TeamsName
                $team=$null
            }
         }
    }
}
  Create-NewTeam -ImportPath "C:\Users\PC\OFFICE 365\Gruppi_class_team.csv"

 

 

 

 

 

This is the error:

 

 

 

 

 

New-Team : Impossibile convalidare l'argomento sul parametro 'MailNickName'. L'argomento è null o vuoto. Fornire un
argomento che non sia null o vuoto ed eseguire di nuovo il comando.
In riga:19 car:49
+                 $group = New-Team -MailNickName $team.Mail -displayna ...
+                                                 ~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [New-Team], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.TeamsCmdlets.PowerShell.Custom.NewTeam

 

 

 

 

 

 

11 Replies

@Luca VALENTINO 

Hi there, i had found a very similar script in another website.

a guy called Andrew West had said in the comments  that  that the alias  and the AccessType should be changed.

 

Its in: https://www.jijitechnologies.com/blogs/create-teams-microsoft-teams-powershell

 

Do let us know if your script works with those changes.

 I managed to create the class groups.
Now I want to insert the members in the various groups but nothing

 

#Connettere a Teams
#Connect-MicrosoftTeams
function Add-Users
{   
    param(   
             $ImportPath
             #,$CurrentUsername,$Role
          )   
    Process
    {
        Import-Module MicrosoftTeams
        $cred = Get-Credential
        $username = $cred.UserName
        Connect-MicrosoftTeams -Credential $cred
        #$teamusers = Import-Csv -Path $ImportPath 
        try{
                $teamusers = $Users -split ";" 
        Write-Host "Start add the users: " $Users
                if($teamusers)
                {
                    for($j =0; $j -le ($teamusers.count - 1) ; $j++)
                    {
                        if($teamusers[$j] -ne $CurrentUsername)
                        {
                            Add-TeamUser -GroupId $GroupName -User $teamusers[$j]
                        }
                    }
                }
            }
        Catch
            {
            }
        }
}
Add-Users -ImportPath "C:\PC\OFFICE 365\Gruppi_membri_team.csv"

@EDU_ictGeek 

Hi,

I tried the PowerShell Script method to add Bulk Team users. It worked :)

https://www.youtube.com/watch?v=CWgMKCbzisA

@EDU_ictGeek @Luca VALENTINO 

I am successfully using the script from Create teams in Microsoft Teams through CSV using PowerShell | JiJi Technologies to create multiple teams, including the channels and adding members simultaneously, from a prepared CSV file.

N.B. I made two small changes to the script.

  • Preparation:
    • I ran PowerShell in Admin mode 
    • I ensured that I had installed the current version of the MicrosoftTeams PowerShell module. I ran the following command in PowerShell (in admin mode) Install-Module -Name MicrosoftTeams -RequiredVersion 1.1.6
  • I made the two highlighted changes to script in the function Create-NewTeam
    • $group = New-Team -MailNickName $team.TeamsName -displayname $team.TeamsName -Template $team.TeamType
    • In the original script it uses -Alias instead of -MailNickName and -AccessType instead of -Template
  • My CSV file had the following headers and example content
    TeamsNameTeamTypeChannelNameOwnersMembers
    21Accounting11EDU_classChannel1; Channel2Teacher1@domain.comMember1@domain.com; member2@domain.com
  • The Team Type is important - you need that in an educational setting to create Class type teams.

@Marius Pretorius 

 

Good afternoon, thank you for this, its really useful.  I will try to emulate to the letter.

 

This is very kind,  thanks again.

@Marius Pretorius @Luca VALENTINO @EDU_ictGeek 

 

Good day!

 

I really need your help... please....

 

I tried your codes but nothing happened....

 

attached is my .csv file for reference and below (here) is my code...

 

function Create-Channel
{
param (
$ChannelName,$GroupId
)
Process
{
try
{
$teamchannels = $ChannelName -split ";"
if($teamchannels)
{
for($i =0; $i -le ($teamchannels.count - 1) ; $i++)
{
New-TeamChannel -GroupId $GroupId -DisplayName

$teamchannels[$i]
}
}
}
Catch
{
}
}
}

function Add-Users
{
param(
$Users,$GroupId,$CurrentUsername,$Role
)
Process
{

try{
$teamusers = $Users -split ";"
if($teamusers)
{
for($j =0; $j -le ($teamusers.count - 1) ; $j++)
{
if($teamusers[$j] -ne $CurrentUsername)
{
Add-TeamUser -GroupId $GroupId -User

$teamusers[$j] -Role $Role
}
}
}
}
Catch
{
}
}
}

function Create-NewTeam
{
param (
$ImportPath
)
Process
{
Import-Module MicrosoftTeams
$cred = Get-Credential
$username = $cred.UserName
Connect-MicrosoftTeams -Credential $cred
$teams = Import-Csv -Path $ImportPath
foreach($team in $teams)
{
$getteam= get-team |where-object { $_.displayname -eq

$team.TeamsName}
If($getteam -eq $null)
{
Write-Host "Start creating the team: " $team.TeamsName
$group = New-Team -DisplayName $team.TeamsName -

displayname $team.TeamsName -Template $team.TeamType
Write-Host "Creating channels..."
Create-Channel -ChannelName $team.ChannelName -GroupId

$group.GroupId
Write-Host "Adding team members..."
Add-Users -Users $team.Members -GroupId $group.GroupId -

CurrentUsername $username -Role Member
Write-Host "Adding team owners..."
Add-Users -Users $team.Owners -GroupId $group.GroupId -

CurrentUsername $username -Role Owner
Write-Host "Completed creating the team: "

$team.TeamsName
$team=$null
}
}
}
}

Create-NewTeam -ImportPath "C:\Users\Admin1234\Desktop\1.csv"

 

 

 

Thank you very much. Best Regards.

@RicMercene 

Please see my post here (Creating bulk class teams from a CSV file). It has the PowerShell module as well as a sample CSV file.

@RicMercene 

It seems your code is missing a function name and opening curly bracket at the beginning and a closing curly bracket below your last line. Your code looks like this:

 


 

function Create-Channel
{
.

.

.

Create-NewTeam -ImportPath "C:\Users\Admin1234\Desktop\1.csv"

 


It should read like this: (I'm only including the missing code)

 

Function New-TeamsFromCSV
{
function Create-Channel
.
.
.
Create-NewTeam -ImportPath "C:\Users\Admin1234\Desktop\1.csv"
}

 

Obviously, you have to take a few steps for your code to execute in PowerShell:

  • you need to use the PowerShell command line to import the module

 

 import-module TheModuleName.psm1

 

  •  I prefer to run PowerShell in Administrator mode to make sure I don't run into permissions problems
  • The name of the module you need to import is the (path and the )name of your .psm1 file
  • and call the function (run it) as shown below.

 

New-TeamsFromCSV

 

Because you are connecting to Teams Admin, you will be asked for your credentials. You need to be a Teams Administrator and provide that username/email address and password. Thereafter you will be flying!

@Marius Pretorius 

 

Good day!

 

Thank you for your response.... I will definitely study and try your program and instruction...

 

Cheers!

 

Best Regards. :)

@Marius Pretorius 

 

Good day!

 

I already tried your code but this is the error message i've received...

RicMercene_1-1619493966172.jpeg

 

below is the whole code...

----

 

Function New-TeamsFromCSV
{
function Create-Channel
{
param (
$ChannelName,$GroupId
)
Process
{
try
{
$teamchannels = $ChannelName -split ";"
if($teamchannels)
{
for($i =0; $i -le ($teamchannels.count - 1) ; $i++)
{
New-TeamChannel -GroupId $GroupId -DisplayName

$teamchannels[$i]
}
}
}
Catch
{
}
}
}

function Add-Users
{
param(
$Users,$GroupId,$CurrentUsername,$Role
)
Process
{

try{
$teamusers = $Users -split ";"
if($teamusers)
{
for($j =0; $j -le ($teamusers.count - 1) ; $j++)
{
if($teamusers[$j] -ne $CurrentUsername)
{
Add-TeamUser -GroupId $GroupId -User

$teamusers[$j] -Role $Role
}
}
}
}
Catch
{
}
}
}

function Create-NewTeam
{
param (
$ImportPath
)
Process
{
Import-Module MicrosoftTeams
$cred = Get-Credential
$username = $cred.UserName
Connect-MicrosoftTeams -Credential $cred
$teams = Import-Csv -Path $ImportPath
foreach($team in $teams)
{
$getteam= get-team |where-object { $_.displayname -eq

$team.TeamsName}
If($getteam -eq $null)
{
Write-Host "Start creating the team: " $team.TeamsName
$group = New-Team -DisplayName $team.TeamsName -

displayname $team.TeamsName -Template $team.TeamType
Write-Host "Creating channels..."
Create-Channel -ChannelName $team.ChannelName -GroupId

$group.GroupId
Write-Host "Adding team members..."
Add-Users -Users $team.Members -GroupId $group.GroupId -

CurrentUsername $username -Role Member
Write-Host "Adding team owners..."
Add-Users -Users $team.Owners -GroupId $group.GroupId -

CurrentUsername $username -Role Owner
Write-Host "Completed creating the team: "

$team.TeamsName
$team=$null
}
}
}
}

Create-NewTeam -ImportPath "C:\Users\Admin1234\Desktop\NewTeams

\NewTeams.csv"

}

Thanks for this, it worked well, the only issue I ran into is that I needed to update my MicrosoftTeams Powershell Module to the latest version. Prior to that then it would run successfully once per day but then after that, fail with an error about MS Graph backend. Anyway, the update resolved this. So thanks again!