Archiving a Microsoft Team is an essential function for organizations that want to preserve team data without actively maintaining or using the team. The Invoke-MgArchiveTeam
cmdlet from the Microsoft Graph PowerShell module enables administrators to archive one or more teams programmatically. This article covers how to use this cmdlet, with syntax, usage examples, tips, possible errors, and real-life use cases that make the process streamlined.
Invoke-MgArchiveTeam -TeamId <String>
The TeamId (required) parameter is the unique identifier of the Microsoft Team you want to archive.
$TeamId = "72bd013b-42ff-4b6e-b84b-5209e3b22bcb"
Invoke-MgArchiveTeam -TeamId $TeamId
This command archives the specified team, ensuring it is set to a read-only state for all users.
$TeamIds = @("72bd013b-42ff-4b6e-b84b-5209e3b22bcb", "33d343b2-123e-42af-9f2c-6dcfd8ac8d45")
foreach ($TeamId in $TeamIds) {
Invoke-MgArchiveTeam -TeamId $TeamId
}
This script archives all the specified teams one by one.
For bulk team archiving, store the TeamId
in a CSV file and process each team from the file. Create a CSV file (e.g., teams-to-archive.csv) with the following structure:
TeamId
72bd013b-42ff-4b6e-b84b-5209e3b22bcb
33d343b2-123e-42af-9f2c-6dcfd8ac8d45
f5a7713b-9c1e-48d2-8a42-d56d634ab213
Run this PowerShell script to archive the teams in bulk:
$Teams = Import-Csv -Path "C:\path\to\teams-to-archive.csv"
foreach ($Team in $Teams) {
Invoke-MgArchiveTeam -TeamId $Team.TeamId
}
This script reads the CSV file and archives each team listed in it.
Invoke-MgUnarchiveTeam
cmdlet.Error | Cause | Solution |
"Resource Not Found (404)" | The specified TeamId does not exist. |
Verify that the TeamId is correct by running the Get-MgTeam cmdlet to check if the team exists. |
"Permission Denied (403)" | The user running the cmdlet does not have permission to archive the team. | Ensure that the user is either a team owner or has the required Microsoft 365 admin permissions, such as the Teams Service Administrator role. |
"Too Many Requests (429)" | Rate limiting can trigger this error when the API is overwhelmed with requests in a short time. | Implement a delay between multiple requests to avoid hitting the rate limit. For example, use Start-Sleep -Seconds 5 between requests in loops. |
The Invoke-MgArchiveTeam
cmdlet is a powerful tool for managing inactive or completed teams within an organization. Archiving a team keeps its data intact and in a read-only state, allowing users to reference the information while preventing changes. Whether you need to archive a single team or manage teams in bulk, this cmdlet provides the flexibility and automation capabilities to streamline your workflow. Regular archiving of inactive teams also helps keep your Microsoft Teams environment organized and reduces clutter.
Make sure to leverage this cmdlet when you need to maintain data while deactivating collaboration features. It's a vital function for both operational efficiency and compliance.
© m365corner.com. All Rights Reserved. Design by HTML Codex