Using Invoke-MgArchiveTeam in Graph PowerShell

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.

Cmdlet Syntax

Invoke-MgArchiveTeam -TeamId <String> 

The TeamId (required) parameter is the unique identifier of the Microsoft Team you want to archive.

Usage Examples

Example 1: Archiving a Single Team

$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.

Example 2: Archiving Multiple Teams

$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.

Example 3: Bulk Archiving Teams Using a CSV File

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.

Cmdlet Tips

  • Read-Only State: When a team is archived, the team becomes read-only. Members can view content but cannot add or modify data.
  • Archived Team Restoration: Teams that are archived can be restored using the Invoke-MgUnarchiveTeam cmdlet.
  • Automation: Archiving teams periodically based on usage data can help keep your environment clean and reduce clutter.
  • Permissions: Ensure you have sufficient privileges to archive teams. Typically, you must be a team owner or have the necessary admin roles.

Possible Errors & Solutions

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.

Use Cases for Archiving Teams

  • End of Project Lifecycle: When a project finishes, its associated team may no longer need active collaboration. Instead of deleting the team, you can archive it for record-keeping and future reference.
  • Departmental Cleanup: In large organizations, departments may create numerous teams over time. Periodically archiving teams that are inactive ensures that only relevant and active teams are accessible, reducing clutter.
  • Education Sector Use Case: Schools can archive teams created for previous semesters or academic years. This allows students and faculty to still access the team for reference while preventing any further updates or discussions.
  • Compliance and Auditing: Teams involved in legal cases or audits can be archived to ensure that all records are preserved in a read-only state, satisfying compliance requirements while maintaining the integrity of historical data.

Conclusion

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