Get all microsoft teams groups with members and owners

The estimated reading time 4 minutes

UPDATE 29/03/2020: this article works, but now Teams Module was relaunched and can do quite more things. See my later article:

NOTE: the following actions ONLY shows team groups created in teams, NO converted O365 groups are shown.
For HTML Reports have a look in comments!

Hi everybody,
I am always faced with the question of how to perform certain evaluations for Microsoft teams in Office 365. Today I would like to introduce how an evaluation of the complete O365 environment works on teams groups.
First, I asked myself, how do you find out which O365 groups of teams were created and which from other applications. You will not find too much information on the internet . Unfortunately, the admin interface of Office 365 / Azure AD does not tell if the group was created with Teams / Yammer etc.
That’s why I’ve been working on this topic.
To find out if a group of teams was created, I connect to the Exchange Online via Powershell
I have already integrated this in my ISE, so if you do this often, you can also read my instructions LINK
The PSSession to Exchange Online is mandatory, as it loads all the necessary cmdlets. The ISE can be used for this because it is very easy to make changes to the script etc.
I used the cmdlet: Get-UnifiedGroup. The output of this query is then filtered again.
$teamsgroups = (Get-UnifiedGroup | Where-Object {($_.ProvisioningOption -eq "ExchangeProvisioningFlags:481") -or ($_.ProvisioningOption -eq "ExchangeProvisioningFlags:3552") }


Because a lot of objects returned after running, I chose a “select” for filtering.

$teamsgroups = (Get-UnifiedGroup | Where-Object {($_.ProvisioningOption -eq "ExchangeProvisioningFlags:481") -or ($_.ProvisioningOption -eq "ExchangeProvisioningFlags:3552") } | Select-Object DisplayName,Alias,ProvisioningOption,SharePointSiteUrl,SharePointDocumentsUrl,AccessType,Language,ExchangeGuid,ManagedBy)


Thus, all O365 groups created by the team users can be displayed.
Not bad at all.
Now I also want to get the group members displayed.

Get-UnifiedGroupLinks -Identity 
 -LinkType Members

As far as not very difficult.
So bringing these two steps together is not as easy as it looks like. 
For this I have built the following Powershell script.


    script for showing all office 365 groups created by microsoft teams


    no parameters needed 

    connect to exchange online first
    or see
    Script:       get-allteams-withmembers-0-1.ps1                                      
    Author:       A. Koehler;
    ModifyDate:   18/03/2018                                                        
    Usage:        identify all teams groups in office 365 and get members
    Version:      0.1

#get all groups created with ms teams (filtered ExchangeProvisioningFlag:481)
#raw powershell command: Get-UnifiedGroup | Where-Object {$_.ProvisioningOption -eq "ExchangeProvisioningFlags:481" } | fl
$teamsgroups = (Get-UnifiedGroup | Where-Object {($_.ProvisioningOption -eq "ExchangeProvisioningFlags:481") -or ($_.ProvisioningOption -eq "ExchangeProvisioningFlags:3552") } | Select-Object DisplayName,Alias,ProvisioningOption,SharePointSiteUrl,SharePointDocumentsUrl,AccessType,Language,ExchangeGuid,ManagedBy) 
#notification for powershell
Write-Host "Getting Office 365 Groups created with MS Teams... " -ForegroundColor Green
#generate array for teamsgroups
$teams = @()
#loop to get information
ForEach ($group in $teamsgroups){
  #get-members of group
  $identity = (($group).ExchangeGuid)
  $members = (Get-UnifiedGroupLinks -Identity "$identity" -LinkType Members | Select-Object PrimarySMTPAddress) 
  $owners = (Get-UnifiedGroupLinks -Identity "$identity" -LinkType Owners | Select-Object PrimarySMTPAddress)   
  $member = (($members).primarySMTPAddress) | Out-String -Width 4096
  $owner = (($owners).primarySMTPAddress) | Out-String
  # Adding pscustomobjets entries to array
  $teams += [pscustomobject]@{
    DisplayName   = ($group).DisplayName
    Alias    = ($group).Alias
    AccessType = ($group).AccessType
    Language = ($group).Language
    Members = ("$member")
    Owner = ("$owner")
#out put in GridView (external window)
Write-Host "Display in Grid View Window " -ForegroundColor Green
$teams | Out-GridView -Title "All Office365 Groups created in MS Teams" 
#out put in powershell
#$teams | Format-Table -AutoSize -Wrap  
#erase content of variables
$teams =$null
$member = $null

This reads all groups with members and also the current manager / owner. We have an overview of the current teams groups within the company.
Criticism and feedback is welcome.
Have fun testing.

Print Friendly, PDF & Email
Was this article helpful?
0 0 votes
Article Rating
Notify of
Oldest Most Voted
Inline Feedbacks
View all comments
5 years ago

this is really great and exactly what I was looking for, what about exporting this to excel?

Jamie Luce
Jamie Luce
6 years ago

Is there anyway to add Created date and when changed date to this script for each team?

6 years ago

this does not account for teams that were created from o365 groups that already existed. seeing that you are only looking for the provisionflag 481, those are groups created from teams. but what about an exchange group that later is converted to a team? is there anything you can think of that could distinguish those? I have a problem when doing a get-unifiedgroup and then trying to sort. if I sort by just the 481 provision flag 368 out of 576 are recognized. I am confident to say those are teams. but I also know from tests I have done I have more teams that that. be it the group started as just an 0365 group, or yammer group or power bi group.