Report · 2 tools

Teams with no owner or only one owner

Summary

Finds teams that have lost their owners, usually because people left. Ownerless teams cannot be managed by members and become a governance and migration risk.

Implementation

Choose your tool. Your choice is remembered on other samples.

Microsoft Graph PowerShell
Connect-MgGraph -Scopes Group.Read.All -NoWelcome
Get-MgGroup -All -Filter "resourceProvisioningOptions/Any(x:x eq 'Team')" -Property Id, DisplayName, Mail |
  ForEach-Object {
    $owners = Get-MgGroupOwner -GroupId $_.Id -All
    [pscustomobject]@{ Team = $_.DisplayName; Mail = $_.Mail; OwnerCount = $owners.Count
      Owners = ($owners.AdditionalProperties.userPrincipalName -join ";") }
  } | Where-Object OwnerCount -lt 2 | Sort-Object OwnerCount |
  Export-Csv .\teams-owners.csv -NoTypeInformation

Prerequisites

  • Graph scopes Group.Read.All
  • Teams Administrator for the PnP version

Output

CSV of teams with owner count and owner names.

Contributors

AuthorRole
Priyanshu UpadhyaySolution Architect, Microsoft 365 and Azure
Disclaimer. These samples are provided as is, without warranty of any kind. Read and test every script in a non-production tenant before you run it, and run reports before any command that changes or deletes data.