As organizations scale, Microsoft Teams sprawl rapidly becomes a governance and data protection liability. Left unchecked, tenants accumulate hundreds of orphaned teams where original creators have left the organization, leaving confidential SharePoint sites and chat channels with zero accountable owners and unmonitored external guest accounts.
PowerShell Automated Teams Sprawl & Orphan Scanner
# ==============================================================================
# Microsoft Teams Sprawl & Orphaned Team Auditor
# ==============================================================================
Connect-MicrosoftTeams -NoWelcome
$allTeams = Get-Team
$report = [System.Collections.Generic.List[PSObject]]::new()
foreach ($t in $allTeams) {
$owners = Get-TeamUser -GroupId $t.GroupId -Role Owner
$guests = Get-TeamUser -GroupId $t.GroupId -Role Guest
$report.Add([PSCustomObject]@{
DisplayName = $t.DisplayName
GroupId = $t.GroupId
OwnerCount = $owners.Count
GuestCount = $guests.Count
IsOrphaned = ($owners.Count -eq 0)
Owners = ($owners.User -join "; ")
})
}
$report | Export-Csv -Path "$PSScriptRoot\Teams_Governance_Report.csv" -NoTypeInformation
Write-Host "Audited $($allTeams.Count) Teams. Report saved." -ForegroundColor Green