Simplify user tasks like bulk creation, updates, password resets, deletions, license checks & more — all from one place.
🚀 Launch ToolkitManaging ownership across Microsoft Teams is critical for governance, lifecycle management, and compliance. This script helps administrators list all Teams owners along with their sign-in status using Graph PowerShell.
# Connect to Microsoft Graph with required scopes
Connect-MgGraph -Scopes "Group.Read.All", "User.Read.All"
# Initialize variables
$headers = @{
"ConsistencyLevel" = "eventual"
}
$teamsOwners = @()
$uri = "https://graph.microsoft.com/v1.0/groups?`$filter=resourceProvisioningOptions/Any(x:x eq 'Team')&`$select=id,displayName&`$top=50"
# Paginate through all Teams
do {
$response = Invoke-MgGraphRequest -Method GET -Uri $uri -Headers $headers
$teams = $response.value
foreach ($team in $teams) {
$teamId = $team.id
$teamName = $team.displayName
# Fetch owners of each team
$ownersUri = "https://graph.microsoft.com/v1.0/groups/$teamId/owners?`$select=displayName,userPrincipalName,accountEnabled"
$ownersResponse = Invoke-MgGraphRequest -Method GET -Uri $ownersUri
foreach ($owner in $ownersResponse.value) {
$teamsOwners += [PSCustomObject]@{
"Team Name" = $teamName
"Owner Name" = $owner.displayName
"Owner Mail" = $owner.userPrincipalName
"Sign In Status" = if ($owner.accountEnabled -eq $true) { "Allowed" } else { "Denied" }
}
}
}
$uri = $response.'@odata.nextLink'
} while ($uri)
# Output results
if ($teamsOwners.Count -eq 0) {
Write-Host "No Microsoft Teams owners found." -ForegroundColor Yellow
} else {
$teamsOwners | Format-Table -AutoSize
}
Here are some ways to extend this script:
This script is extremely useful for:
Error | Cause | Solution |
Access Denied | Missing permissions | Ensure Group.Read.All and User.Read.All Graph API scopes are granted |
Invoke-MgGraphRequest returns null | Pagination not handled properly | Always check for @odata.nextLink to fetch all records |
Sign In Status missing | Some owners may be external guests | Include userType and accountEnabled check for better clarity |
This script provides a clean, efficient, and extensible way to fetch all Microsoft Teams owners using Graph PowerShell. Whether you're handling governance, auditing, or automation—this is a must-have tool in your IT admin toolkit.
💡 Tip: For better automation, schedule this script to run weekly and store results in a centralized location for tracking changes in ownership.
© m365corner.com. All Rights Reserved. Design by HTML Codex