đź”§ New: User Management Graph PowerShell Toolkit

Simplify user tasks like bulk creation, updates, password resets, deletions, license checks & more — all from one place.

🚀 Launch Toolkit

Find Microsoft Teams Without Owners using Microsoft Graph PowerShell

One of the most overlooked issues in Microsoft Teams administration is when a Team ends up with no owners. This usually happens when the original owner leaves the organization or changes roles without assigning a replacement. The problem? No one can manage membership, approve requests, or adjust settings for that Team. Over time, these "orphaned Teams" pile up, creating security risks, governance gaps, and frustrated end users who can’t get their issues resolved.

To tackle this, you can use a simple Graph PowerShell script that scans your tenant and identifies all Teams that don’t have an owner. Once you have this list, you can take action—either reassigning ownership, archiving the Team, or notifying administrators.


i) Script

# Connect to Microsoft Graph with required scopes
Connect-MgGraph -Scopes "Group.Read.All", "User.Read.All", "Directory.Read.All"

# Get all groups that are Teams-enabled
$teamsGroups = Get-MgGroup -Filter "resourceProvisioningOptions/Any(x:x eq 'Team')" -All
                                
foreach ($group in $teamsGroups) {
    # Get owners of the group
    $owners = Get-MgGroupOwner -GroupId $group.Id
                                
    if ($owners.Count -eq 0) {
        Write-Output "Team '$($group.DisplayName)' (ID: $($group.Id)) has no owners."
    }
}
                                

ii) How the Script Works

  1. Connects to Graph
  2. Uses delegated scopes Group.Read.All, User.Read.All, and Directory.Read.All to read groups and owners.

  3. Finds Teams-enabled Groups
  4. Filters Microsoft 365 groups whose resourceProvisioningOptions contains "Team"—i.e., groups that back Microsoft Teams.

  5. Checks Ownership
  6. For each Teams group, retrieves owners with Get-MgGroupOwner. If the owner collection is empty, it prints a line indicating the Team has no owners.

  7. Outputs Results
  8. The script writes a simple message for each unowned Team; it’s easy to capture or redirect to a file.


iii) Further Enhancements

  • Export to CSV: Pipe the results into Export-Csv for auditing or ticketing.
  • Add Fallback Owners: Automatically assign a fallback admin if no owners are found (e.g., via Add-MgGroupOwnerByRef).
  • Notify via Email/Teams: Send a summary email to IT or post to a governance channel.
  • Include Metadata: Also fetch and include properties like CreatedDateTime, Visibility, MailNickname.
  • Schedule It: Run daily/weekly with Task Scheduler or Azure Automation and store historical snapshots.

iv) Use Cases

  • Governance & Compliance: Ensure every Team has at least two owners as per policy.
  • Operational Hygiene: Prevent orphaned Teams after role changes or departures.
  • Lifecycle Management: Identify candidates for archival or deletion workflows.
  • Security Posture: Reduce risk of unmanaged sharing and membership drift.

v) Possible Errors & Solutions

Error Cause Solution
Insufficient privileges to complete the operation Missing or unconsented Graph scopes Reconnect using the exact scopes shown and ensure consent is granted.
The term 'Get-MgGroup' is not recognized Microsoft Graph module not installed/loaded Install Microsoft.Graph module and re-run Connect-MgGraph.
Empty results (no Teams found) No Teams-backed groups, or filter mismatch Verify Teams exist; remove the filter temporarily to validate group retrieval.
Throttling / intermittent failures Large tenants or frequent calls Add delays/retries, or page/parallelize responsibly if you extend the script.
Access denied on owners Directory role restrictions / conditional access Run as an account with directory read permissions and compliant sign-in.

vi) Conclusion

This lightweight script quickly surfaces Teams with no owners, a key governance gap. From here, you can export findings, notify stakeholders, or auto-remediate by assigning fallback owners—keeping your Microsoft Teams environment healthy, compliant, and manageable.


Graph PowerShell Explorer Widget

20 Graph PowerShell cmdlets with easily accessible "working" examples.


Permission Required

Example:


                


                


                

© m365corner.com. All Rights Reserved. Design by HTML Codex