Skip to content
Knowledge Base
Česky

Office · Teams

Office365 Teams: PowerShell automation of team membership

Robert Haken 1 min read Markdown ↓

Office365 Academic (Education) does not support organization-wide teams. To get over this limitation, you can maintain the membership by a simple PowerShell script:

Get-MsolUser -All | Where-Object { $_.Licenses.ServiceStatus.ServicePlan.ServiceName -match "TEAMS"} | ForEach-Object { [pscustomobject]@{User = $PSItem.UserPrincipalName} } | Add-TeamUser -GroupId f29dbfc0-d118-4480-a6f7-22048a0809d0 -Role Member

In short:

  1. Take all Azure Active Directory users.
  2. Filter them to those having a Teams license assigned.
  3. Transform the data to input usable for Add-TeamUser cmdlet.
  4. Add the users to the team (you will get the GroupId by using Get-Team cmdlet)

You can run the script repeatedly, just the missing users will be added. You can modify the script easily and apply any additional conditions when adding the users to the group.

Might help:

Install-Module MicrosoftTeams
Install-Module MSOnline

Connect-MicrosoftTeams
Connect-MsolService

Get-Team
Robert Haken · HAVIT Software Architect, Founder at HAVIT, Microsoft MVP - ASP.NET/IIS.
Has 53 articles in the knowledge base.
All articles by this author →
Read next
Discussion

Leave a reply

Discover more from HAVIT Knowledge Base

Subscribe now to keep reading and get access to the full archive.

Continue reading