Jump to content

Recommended Posts

Posted (edited)

I need to add a user to a couple of hundred teams. Anything I Google just comes back with adding multiple users to A team, which is round the wrong way. I've had a go at editing an existing script but just couldn't get the syntax correct. I have all the Teams I need her in, in a CSV file.

 

Thank you

 

Stuart

Edited by Jawloms
Posted

Hi Stuart, this is what I've been using, the CSV just needs two columns with the headings GroupID and Member

 

#Get Credentials to connect$Credential = Get-Credential #Connect to Exchange OnlineConnect-ExchangeOnline -Credential $Credential -ShowBanner:$False #PowerShell to Import Members to office 365 group from CSVImport-CSV "C:\Temp\XXX.csv" | ForEach-Object { Add-UnifiedGroupLinks -Identity $_.GroupID -LinkType Members -Links $_.Member Write-host -f Green "Added Member '$($_.Member)' to Office 365 Group '$($_.GroupID)'"} #Disconnect Exchange OnlineDisconnect-ExchangeOnline -Confirm:$False

  • Thanks 1
Posted
Thanks for that, but it's connecting to Exchange online which we don't currently use. I set all my Teams up using Import-Module MicrosoftTeams and Connect-MicrosoftTeams. Would it still work using Exchange online commands for me?
Posted

This is one of the scripts I wrote for ours:

 

Connect-MicrosoftTeams

$Roster = import-Csv \\Itoffice-pc01\c$\File.csv

ForEach ($Student in $Roster)

{

Get-Team -DisplayName $Student.Team | Add-TeamUser -User $Student.UserPrincipalName -Role Member

}

 

From memory two columns one names Team with the team name and UserPrincipalName as the headers.

  • Thanks 1
Posted

TBH A Team is an UnifiedGroup, so you are using Exchange Online, even if that isn't where your user mailboxes are stored.

 

If you really want to use the microsoftteams module though, you just need to tweak script, swapping out add-UnifiedGroupLinks for add-teamuser

 

edit: ninja'd

  • Thanks 1
Posted
Just bear in mind that doing this will absolutely destroy the performance of the Teams client. I remember adding being asked to add teachers to every class team in their subject or year, then being asked to take them out again very soon afterwards.
  • Thanks 1
Posted
I don't ever recall checking to be honest, but considering that the fat client is essentially a wrapper for the browser client in Electron I would expect similar problems, yes.
  • Thanks 2

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 account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...