← Back to articles PowerShell

Auditing Microsoft Teams Ownership & Member Sprawl with PowerShell & Microsoft Graph API

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

Was this article helpful?

🎯
MSEndpoint Academy

Assess Your Microsoft 365 & Intune Skills (MD-102)

100% Free • 5 Min

Applying this guide in production? Test your technical readiness against real exam scenarios from Microsoft 365 Certified: Endpoint Administrator (MD-102). Identify your strengths and knowledge gaps instantly.

💡 Express Knowledge Check Question 1 of 10

Which official utility is required to convert a Win32 application installer (.exe) into the package format (.intunewin) for deployment via Microsoft Intune?

🔒 100% Free 📊 Instant Scorecard 🤖 AI Explanations
Take Full Diagnostic Exam (10 Questions)

🎓 Ready to go deeper?

Practice real MD-102 exam questions, get AI feedback on your weak areas, and fast-track your Intune certification.

Start Free Practice → Book a Session
Souhaiel Morhag
Souhaiel Morhag
Microsoft Endpoint & Modern Workplace Engineer

Souhaiel Morhag is a Microsoft Intune and endpoint management specialist with hands-on experience deploying and securing enterprise environments across Microsoft 365. He founded MSEndpoint.com to share practical, real-world guides for IT admins navigating Microsoft technologies — and built the MSEndpoint Academy at app.msendpoint.com/academy, a dedicated learning platform for professionals preparing for the MD-102 (Microsoft 365 Endpoint Administrator) certification. Through in-depth articles and AI-powered practice exams, Souhaiel helps IT teams move faster and certify with confidence.

Related Articles

Popular on MSEndpoint