How to List and Restore Deleted Microsoft 365 Groups Using Graph PowerShell

Microsoft 365 Groups that have been deleted remain in a soft-deleted state for 30 days, after which they are permanently removed. During this period, administrators can recover these groups using Graph PowerShell.

This guide covers:

  • Listing deleted Microsoft 365 groups using Get-MgDirectoryDeletedItemAsGroup
  • Restoring a deleted Microsoft 365 group using Restore-MgDirectoryDeletedItem
  • Addressing potential errors and ensuring a smooth recovery process

List Deleted Microsoft 365 Groups

To view all deleted Microsoft 365 Groups, run:

Get-MgDirectoryDeletedItemAsGroup | Select-Object Id, DisplayName, Description, Mail | Format-Table -AutoSize

This command retrieves all deleted groups along with their ID, Display Name, Description, and Mail properties.

Export Deleted Groups to CSV

Get-MgDirectoryDeletedItemAsGroup | Export-Csv -Path "C:\DeletedM365Groups.csv" -NoTypeInformation

Note: Exporting deleted groups into a CSV file ensures that you have a backup reference before proceeding with a restore operation.

Restore a Deleted Microsoft 365 Group

Once you have identified the group you want to restore, use the Restore-MgDirectoryDeletedItem cmdlet.

Restore-MgDirectoryDeletedItem -DirectoryObjectId dabf9bd7-494c-450c-a359-4bb07216701c

Replace dabf9bd7-494c-450c-a359-4bb07216701c with the ID of the deleted group you want to recover.

End-to-End Restore Process

  1. Retrieve all deleted M365 groups:
    Get-MgDirectoryDeletedItemAsGroup | Format-Table Id, DisplayName
  2. Identify the DirectoryObjectId of the group you want to restore.
  3. Run the restore command:
    Restore-MgDirectoryDeletedItem -DirectoryObjectId <GroupId>
  4. Verify if the group has been restored:
    Get-MgGroup -Filter "DisplayName eq 'Restored Group Name'"

Cmdlet Tips

  • Get-MgDirectoryDeletedItemAsGroup only returns groups in the soft-deleted state. If a group is permanently deleted, it cannot be restored.
  • The Group ID is required to restore a deleted group. If you do not have it, use:
  • Get-MgDirectoryDeletedItemAsGroup | Select-Object Id, DisplayName
  • Restoring a group also restores its associated resources, such as SharePoint sites, Teams, and Planner data, as long as it is within the 30-day retention period.
  • If the restore is unsuccessful, check whether the group has already been permanently deleted or whether the retention period has expired.

Frequently Asked Questions

  • How long are deleted Microsoft 365 groups retained?
  • Deleted Microsoft 365 groups are retained in a soft-deleted state for 30 days. After this period, the group is permanently deleted and cannot be recovered via Graph PowerShell or the admin center.

  • Can I restore a group that was deleted more than 30 days ago?
  • No. Once the 30-day grace period has passed, the group and all associated data (including Teams, SharePoint, and Planner content) are irretrievably deleted.

  • Will all group properties and data be fully restored?
  • Most properties, including group name, description, members, and content in linked services (like Teams, Planner, and SharePoint), are restored. However, some settings such as external sharing permissions or custom configurations might need to be manually reviewed or reconfigured.


Possible Errors and Solutions

Error Cause Solution
Resource not found (404) The group was permanently deleted. Check the retention period and ensure it is within 30 days.
Insufficient privileges to complete the operation You lack the required permissions. Run Connect-MgGraph -Scopes Group.ReadWrite.All and ensure you have Global Admin or Group Administrator rights.
DirectoryObjectNotFound Incorrect Group ID or group no longer exists. Verify the Group ID using Get-MgDirectoryDeletedItemAsGroup.

Restoration is Time-Limited
Deleted Microsoft 365 groups are retained for only 30 days in a soft-deleted state. After that, they are permanently deleted and cannot be recovered using Graph PowerShell or any other method.
Callout 2:Not All Properties Are Retained Post-Restore
While group settings, membership, and content in connected services (like Teams or SharePoint) are restored, some attributes like custom settings or external guest permissions may require manual review after restoration.

Conclusion

Microsoft 365 Groups remain recoverable for 30 days after deletion, and using Graph PowerShell, administrators can quickly list and restore them.

By following the steps outlined in this guide, you can:

  • Identify deleted groups
  • Export details for future reference
  • Restore groups efficiently
  • Avoid common errors

Try it out in your environment and customize it based on your requirements. Let us know if you found this useful by writing to us @ m365corner@gmail.com