All scripts
Microsoft 365 655
Get-TeamsArchivedTeamsReport
Lists every archived team along with when it was created and its owners, useful for deciding which archived teams are safe to delete outright versus keep for reference.
Get-TeamsArchivedTeamsReport.ps1
<#
.SYNOPSIS
Reports all archived teams with owner and creation details.
.DESCRIPTION
Lists every team currently in an archived state along with its
owners and creation date, useful for a periodic cleanup review to
decide what gets deleted outright versus kept for reference.
.EXAMPLE
.\Get-TeamsArchivedTeamsReport.ps1
.NOTES
Requires the MicrosoftTeams and Microsoft.Graph.Groups modules with
active sessions.
.AUTHOR
Shehryar Hassan
#>
$teams = Get-Team | Where-Object { $_.Archived -eq $true }
$report = foreach ($team in $teams) {
$group = Get-MgGroup -GroupId $team.GroupId
$owners = Get-MgGroupOwner -GroupId $team.GroupId | ForEach-Object { $_.AdditionalProperties.displayName }
[pscustomobject]@{
TeamName = $team.DisplayName
CreatedDate = $group.CreatedDateTime
Owners = $owners -join ", "
}
}
$report | Sort-Object CreatedDate | Format-Table -AutoSize
Write-Host "$($report.Count) archived team(s) found" -ForegroundColor Cyan
Read it before you run it, and test in a safe tenant first.