Back to script library
Entra / Microsoft 365 · Teams

Report teams owners

A quick script to show how to use the Microsoft Graph PowerShell SDK to generate a list of Teams and their owners.

Connect & set up

Run these once per session. All scopes are read-only unless the script makes changes.

Connect-MgGraph -NoWelcome -Scopes Directory.Read.All

Run it

The main script. Copy it, or download the .ps1 and run it from your console.

Connect-MgGraph -NoWelcome -Scopes Directory.Read.All
Write-Host "Finding teams..."
[array]$Teams = Get-MgGroup -Filter "resourceProvisioningOptions/any(x:x eq 'Team')" -All -PageSize 999 | Sort-Object DisplayName
If ($Teams) {
Write-Host ("Found {0} teams. Now processing..." -f $Teams.count)
} Else {
Write-Host "No teams found - exiting"; break
}
$Report = [System.Collections.Generic.List[Object]]::new()
[int]$i = 0
ForEach ($Team in $Teams) {
$i++
Write-Host ("Processing {0} ({1}/{2})..." -f $Team.DisplayName, $i, $Teams.count)
[array]$Owners = Get-MgGroupOwner -GroupId $Team.Id
If ($Owners) {
$TeamOwners = $Owners.AdditionalProperties.displayName -Join ", "
} Else {
$TeamOwners = "No team owners"
}
$DataLine = [PSCustomObject][Ordered]@{
Team = $Team.displayName
Owners = $TeamOwners
Visibility = $Team.Visibility
ID = $Team.Id
}
$Report.Add($DataLine)
}
$Report | Out-GridView
Attribution