Simplify user tasks like bulk creation, updates, password resets, deletions, license checks & more — all from one place.
🚀 Launch ToolkitMonitoring recently created Microsoft Teams can help administrators track changes, enforce naming conventions, or spot unexpected activity. With Microsoft Graph PowerShell, you can easily fetch Teams created in the last 30 days—along with details like team name, description, owner, and type.
# Connect to Microsoft Graph with necessary permissions
Connect-MgGraph -Scopes "Group.Read.All", "User.Read.All", "Directory.Read.All"
# Set threshold date
$thresholdDate = (Get-Date).AddDays(-30)
# Prepare results array
$recentTeams = @()
# Proper Graph API endpoint
$uri = "https://graph.microsoft.com/v1.0/groups?`$filter=resourceProvisioningOptions/Any(x:x eq 'Team')&`$select=id,displayName,description,createdDateTime"
# Loop for pagination
do {
try {
$response = Invoke-MgGraphRequest -Uri $uri -Method GET
$teams = $response.value
foreach ($group in $teams) {
try {
if ($group.createdDateTime) {
$created = [datetime]$group.createdDateTime
if ($created -ge $thresholdDate) {
# Fetch team owner
$ownerUri = "https://graph.microsoft.com/v1.0/groups/$($group.id)/owners?`$select=displayName,userPrincipalName"
$ownerResponse = Invoke-MgGraphRequest -Uri $ownerUri -Method GET
$owner = $ownerResponse.value | Select-Object -First 1
# Add to results
$recentTeams += [PSCustomObject]@{
"Team Name" = $group.displayName
"Team Description" = if ($group.description) { $group.description } else { "N/A" }
"Team Owner" = if ($owner) { "$($owner.displayName) <$($owner.userPrincipalName)>" } else { "N/A" }
"Team Type" = "Microsoft Team"
}
}
} else {
Write-Warning "Group '$($group.displayName)' has no creation date."
}
} catch {
Write-Warning "Error processing group '$($group.displayName)': $_"
}
}
$uri = $response.'@odata.nextLink'
} catch {
Write-Warning "Error retrieving teams: $_"
break
}
} while ($uri)
# Output result
if ($recentTeams.Count -eq 0) {
Write-Host "No Microsoft Teams created in the last 30 days were found." -ForegroundColor Yellow
} else {
$recentTeams | Format-Table -AutoSize
}
Let's break it down step-by-step:
The script connects to Microsoft Graph with permissions to read group and user data.
The thresholdDate is set to 30 days before the current date.
Using Invoke-MgGraphRequest, the script fetches only Teams by filtering resourceProvisioningOptions.
Each team's createdDateTime is compared with the threshold date to determine if it was created recently.
For each qualifying team, the script fetches one of its owners (name and email).
The result is displayed in the console in a tabular format with key headers.
You can build on this script in several ways:
Add | Export-Csv "RecentTeams.csv" -NoTypeInformation to save the output.
| Error | Cause | Solution |
| 403 Forbidden | Missing permission scopes | Ensure the user has Group.Read.All, Directory.Read.All, and User.Read.All permissions. |
| Cannot convert null to type "System.DateTime" | Some groups have null createdDateTime | Script handles this using a try block and skips such entries. |
| Unexpected token '??' | You're using PowerShell 5.1 | Use if () { } else { } instead of ??, which is only supported in PowerShell 7+. |
This script provides a powerful way to track newly created Microsoft Teams in your environment. It's helpful for auditing, onboarding, or compliance monitoring. With a few enhancements, you can extend it into a complete reporting solution for Teams management.
© m365corner.com. All Rights Reserved. Design by HTML Codex