ScottD536 Posted June 15, 2023 Posted June 15, 2023 Hi All, Does anyone happen to know how, or even currently perform bulk creation operation on Teams? I am trying to create around 60 Teams, all with multiple users registered as "Owner", but I seem to be hitting a wall whilst trying to add multiple users as Owner. Example: I have 60 classes, all named "Teaching Group 1- 60", I want to create all of these groups in one go, and assign myself and 2 other users as "Owners" (basically as admin). I am currently using the following to generate an individual Team: New-Team -DisplayName "Teaching Group 1" -Owner "[email protected]" This seems to work, but doesnt factor in the multiple Owners problem. I would like to be able to draw variables from a .csv possibly in order to create and assign these Teams, but nothing I try seems to work, has anyone managed to do anything like this at all? Thank you.
Jawloms Posted June 15, 2023 Posted June 15, 2023 I seem to remember that you can't create Teams as a "Class" using PowerShell. Hopefully I've either got that wrong, or they've fixed it by now. I have scripts to Archive Teams and to rename Teams if you're interested? We rename our "Year 7 Geography" to "Year 8 Geography" for example.
nwkeene Posted June 15, 2023 Posted June 15, 2023 When i did the bulk creation for Teams, i came across this issue. When you create the team, as the instruction is one line, you can only add one person. I got round it by creating the Teams and making myself the owner. Then getting the group ID of the Team. then you can do actions against the group ID like adding people as owners or members from a csv file. Then i run another script to remove myself from the team. I found using the Group Id was the best way of doing this. using the team name meant using azure lookups, which in my scripts, didn't work. happy to share the basic scripts i used...
nwkeene Posted June 15, 2023 Posted June 15, 2023 I seem to remember that you can't create Teams as a "Class" using PowerShell. Hopefully I've either got that wrong, or they've fixed it by now. I have scripts to Archive Teams and to rename Teams if you're interested? We rename our "Year 7 Geography" to "Year 8 Geography" for example. You can create a 'class' type team in powershell. I used the following: $csv = import-csv d:\teamsps\7d-Hi1-class.csv $csv | foreach-object { $TeamName = $_.class $Owner = $_.owner $TeamDescription = $TeamName $group = New-Team -template EDU_class -DisplayName "$TeamName" -Description "$TeamDescription" -Owner "$Owner" } which uses a csv with headers of 'class' and 'owner'. its basic, but did the job.
TechMonkey Posted June 15, 2023 Posted June 15, 2023 You are correct that you can't add multiple owners when creating. But you can set the output from the new-team to a variable and then use that to get the ID and add more. Something like: $newTeam = New-Team -DisplayName "Teaching Group 1" -Owner "[email protected]" Add-TeamUser -GroupID $newTeam.GroupID -User "[email protected]" You may need to add a loop that checks if the $newTeam.GroupID is null or blank and add the new user once it has a variable as I found the Teams powershell cmdlets to be slow.
chazzy2501 Posted June 16, 2023 Posted June 16, 2023 So why do this rather than use Microsoft SDS, it is made for this very purpose.
ScottD536 Posted June 16, 2023 Author Posted June 16, 2023 (edited) Was there an easy way to get an output of the GroupID's you had just created? I dont mind running a script for generating and then another for adding other Owners. Edited June 16, 2023 by ScottD536
ScottD536 Posted June 16, 2023 Author Posted June 16, 2023 So why do this rather than use Microsoft SDS, it is made for this very purpose. Honestly hadnt heard of this until now, but it doesnt support our MIS anyway. - - - Updated - - - When i did the bulk creation for Teams, i came across this issue. When you create the team, as the instruction is one line, you can only add one person. I got round it by creating the Teams and making myself the owner. Then getting the group ID of the Team. then you can do actions against the group ID like adding people as owners or members from a csv file. Then i run another script to remove myself from the team. I found using the Group Id was the best way of doing this. using the team name meant using azure lookups, which in my scripts, didn't work. happy to share the basic scripts i used... Was there an easy way to get an output of the GroupID's you had just created? I dont mind running a script for generating and then another for adding other Owners. If you have the scripts then I would be very grateful thank you!
nwkeene Posted June 16, 2023 Posted June 16, 2023 to get the group ID's, i used: Get-Team |Select GroupId, DisplayName which gives all the GroupIDs in the powershell window. I cut and pasted it into a spreadsheet and mangled it to get the ID's i needed for the actions i needed. I'm no powershell expert but you could probably pipe the output of that command into a file. To find just one ID, use: Get-Team -DisplayName "TEAM NAME HERE" hope that helps.
nwkeene Posted June 16, 2023 Posted June 16, 2023 my 'add students' PS script is listed below. You need a csv with headers: of student and GroupID $csv = import-csv d:\teamsps\students-extras-2.csv $csv | foreach-object { $student = $_.student $GroupID = $_.GroupID Add-TeamUser -GroupId "$GroupID" -User "$student" -Role Member } I did similar for teachers, but made the '-role Member' bit to be '-role Owner'. I found it easier to do it students and Teachers separately than work out a script to combine the operations. If you're a script junkie, its probably very easy. I'm a big believer in 'KISS'... 'keep it simple, stupid!' as it helps my colleagues if they find themselves having to do this.
TechMonkey Posted June 16, 2023 Posted June 16, 2023 I used Write-Host "Finding Team ID" -foregroundColor Yellow DO { #Get the ID of the Team $teamFound = Get-Team -Archived $false -DisplayName $channel.Team | Where-Object {$_.DisplayName -eq $channel.Team} Write-Host "Currently:" $teamFound.DisplayName } Until (![string]::IsNullOrWhiteSpace($teamFound.GroupID)) Write-Host "Team Found! ID:" $teamFound.GroupID -foregroundColor Green Where $channel is the current record from a CSV that contains owner, ownerEmail, Team. This loop keeps checking if the Team can be found and that the GroupID isn't null or blank. THis was the issue I was talking about before. Teams would be created but not yet available so the script would fail. This basically makes the script wait until the team is found.
chazzy2501 Posted June 16, 2023 Posted June 16, 2023 err, SDS just accepts CSVs so just create a report in your MIS that complies with that formatting..and it's done.. next year will be easy to, or mid year changes. it also has all of the end of year markdown features that you've not stumbled into yet. (archive old teams by changing their names and making them read only, making new teams with old names, new users and new owners) as class names remain the same but new teachers and pupils n wot not.
TechMonkey Posted June 16, 2023 Posted June 16, 2023 Mine weren't for teams in the MIS and aren't for classes so SDS was no good.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now