Let’s discuss how to Restore a deleted Microsoft 365 group using Microsoft Graph API and PowerShell. If you’re an administrator working with Microsoft Intune or Microsoft Entra, creating users in Entra and adding them to specific groups is a routine part of your day. You may also frequently receive requests to add users to existing Microsoft Entra Microsoft 365 or security groups.
Groups empower resource owners and Microsoft Entra directory administrators to efficiently assign a predefined set of permissions to all members. Furthermore, directory or resource owners can delegate group management to individuals such as department heads or help desk admins, enabling them to add or remove members as needed.
In certain scenarios, you or someone within your organization may intentionally or accidentally delete groups from Microsoft Intune or Microsoft Entra. If you later need to restore those deleted groups, it’s important to understand the recovery options available. This raises a key question: How can you automate the restoration of deleted groups?
This article delves into the available methods for recovering deleted Microsoft 365 groups both manually and through automation. We’ll walk through the recovery process using the Microsoft Intune or Microsoft Entra center, and then demonstrate how to leverage Microsoft Graph API and PowerShell scripting to automate group restoration efficiently.
Table of Contents
Understanding Microsoft 365 Groups
When creating a new group in Microsoft Entra or Intune, you’ll notice two primary group types available: Security Groups and Microsoft 365 Groups. Security Groups are used to manage access to shared resources. Members of a security group can include users, devices, and service principals.

What is Microsoft 365 Groups? Microsoft 365 Groups are purpose-built for collaboration across Microsoft 365 applications such as Teams, SharePoint, and Outlook. Similar to Security Groups, both users and service principals can be assigned as group owners.
With Microsoft 365 Groups, permissions are automatically managed across integrated resources. When users are added to a group, they’re instantly granted access to the associated tools without the need for manual permission assignments.
- Track All Intune Policy and App Assignments for Users Devices and Entra ID Groups with Assignment Checker
- How to Assign Custom Intune Role Based Access to Azure AD Groups using Microsoft Entra PIM
However, there is a key distinction: Microsoft 365 Groups differ from other group types like Security Groups, Distribution Lists, and Mail-enabled Security Groups in terms of collaboration features, membership flexibility, and integration capabilities.
Feature | Description |
---|---|
Owners | Can be users or service principals |
Members | Only user accounts are supported (no devices or service principals) |
External Users | Can be added if enabled by the administrator |
Dynamic Membership | Supported via Microsoft Entra ID; members assigned based on user attributes |
Restore Deleted Microsoft 365 Group Manually
When a Microsoft 365 group is deleted, it enters a 30-day retention period, commonly referred to as a soft delete. During this time, the group and its associated resources remain recoverable. If the group is not restored within 30 days, it is permanently deleted, and all related content becomes unrecoverable.
- How to Assign Custom Intune Role Based Access to Azure AD Groups using Microsoft Entra PIM
- Best Practices for Creating Entra ID Dynamic Groups for Intune
- Create AAD Dynamic Groups based on Domain Join Type Hybrid Azure AD and Azure AD
When a deleted Microsoft 365 group is restored, all its core components and associated services are reinstated. This includes the Microsoft Entra ID object, along with its properties and group members, as well as the group’s email addresses.
- Sign in to the Microsoft Intune admin center
- Click on Groups
- Select Deleted groups.

NOTE! 30 days after original deletion, groups are permanently deleted.
To restore a Deleted group, begin by selecting the group you wish to recover. In this case, the group is named HTMD Test Group. Once selected, you will be presented with two options: Delete permanently and Restore group. Choose the Restore Group option to initiate the recovery process and bring the group back to its active state.

Restore Deleted Microsoft 365 Group using Graph API
Microsoft Graph is an API (Application programming interface) that provides a single endpoint for accessing data, intelligence, and insights from Microsoft 365 and other Microsoft Cloud services. Let’s use Graph API to restore deleted Microsoft 365 Group.
- Best Guide to Restart Intune Devices Remotely using Microsoft Graph API and PowerShell
- Best Guide to Run Intune Device Query with Microsoft Graph API
- Automate Microsoft Intune Device Compliance Report using Graph API
The below mentioned endpoint will retrieves the Group ID details for you. Here, you should note down the Object ID of the target group to proceed further.
- Sign in to the Graph Explorer with your credentials.
- Click on Run query after typing the URL below. You should use the GET API request method
https://graph.microsoft.com/v1.0/directory/deletedItems/microsoft.graph.group?$filter=displayName eq 'Group Name'&$select=id,displayname
Make sure to replace the group name, i.e., HTMD Test Group with your group name. Within seconds of clicking Run query, you will receive a success message with the text OK -200.
Permission | Description | Admin consent required |
---|---|---|
Group.ReadWrite.All | App acts independently, with full access to all groups in the tenant. | Yes |
- Best Practices for Creating Entra ID Dynamic Groups for Intune
- Create AAD Dynamic Groups based on Domain Join Type Hybrid Azure AD and Azure AD

Make sure to note down the Object ID of the target group to proceed further. We will use this Object ID in the next URL. Change the request method from GET to POST and paste the below endpoint. Make sure to replace Object ID.
https://graph.microsoft.com/v1.0/directory/deletedItems/e246f37a-6d38-4b84-844a-b426fa7b18e6/microsoft.graph.restore

Click on Run query, within seconds of clicking Run query, you will receive a success message with the text OK -200. You can see the output in Response preview panel.
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#directoryObjects/$entity",
"@odata.type": "#microsoft.graph.group",
"id": "e246f37a-6d38-4b84-844a-b426fa7b18e6",
"deletedDateTime": null,
"classification": null,
"createdDateTime": "2025-08-12T06:07:26Z",
"creationOptions": [],
"description": "HTMD Test Group",
"displayName": "HTMD Test Group",
"expirationDateTime": null,
"groupTypes": [
"Unified"
],
"isAssignableToRole": null,
"mail": "HTMDTestGroup@r3fx.onmicrosoft.com",
"mailEnabled": true,
"mailNickname": "HTMDTestGroup",
"membershipRule": null,
"membershipRuleProcessingState": null,
"onPremisesDomainName": null,
"onPremisesLastSyncDateTime": null,
"onPremisesNetBiosName": null,
"onPremisesSamAccountName": null,
"onPremisesSecurityIdentifier": null,
"onPremisesSyncEnabled": null,
"preferredDataLocation": null,
"preferredLanguage": null,
"proxyAddresses": [
"SMTP:HTMDTestGroup@r3fx.onmicrosoft.com"
],
"renewedDateTime": "2025-08-13T06:15:47Z",
"resourceBehaviorOptions": [],
"resourceProvisioningOptions": [],
"securityEnabled": true,
"securityIdentifier": "S-1-12-1-3796300666-1266969912-649349764-3860364282",
"theme": null,
"uniqueName": null,
"visibility": "Private",
"onPremisesProvisioningErrors": [],
"serviceProvisioningErrors": []
}
PowerShell Script to Restore Deleted Microsoft 365 Groups
Well, I have restored the deleted Microsoft 365 Groups using Microsoft Graph API. Let’s write a PowerShell script to Restore Deleted Microsoft 365 Groups.
NOTE! Use the Connect-MgGraph command to sign in with the required scopes. You'll need to sign in with an admin account to consent to the required scopes.
- Best Guide to Install Microsoft Graph PowerShell Modules
- Complete Guide to Install the New Microsoft Entra PowerShell Module
- How to Pause Intune Config Refresh Feature on Windows Device using Microsoft Graph API
I have designed the following code, which prompts you to enter the name of the group you would like to restore. Make sure the Microsoft Graph module is installed. However, the code below will ensure it gets installed if it’s not already present.
##########################################################################
#Restore-M365DeletedGroups.ps1
#Author : Sujin Nelladath
#LinkedIn : https://www.linkedin.com/in/sujin-nelladath-8911968a/
##########################################################################
# Install Microsoft Graph module
Install-Module Microsoft.Graph -Force -Scope CurrentUser
# Connect to Microsoft Graph with required scope
Connect-MgGraph -Scopes "Group.ReadWrite.All"
# Prompt user for group name
$GroupName = Read-Host "Enter the name of the Microsoft 365 group you want to restore"
# Fetch all deleted groups
$deletedGroups = Get-MgDirectoryDeletedGroup
# Find the group by display name
$targetGroup = $deletedGroups | Where-Object { $_.DisplayName -eq $GroupName }
if (!$targetGroup)
{
Write-Host "Group '$GroupName' not found in deleted items." -ForegroundColor Red
}
else
{
try
{
Restore-MgDirectoryDeletedItem -DirectoryObjectId $targetGroup.Id
Write-Host "Group '$GroupName' has been successfully restored." -ForegroundColor Green
}
catch
{
Write-Host "Failed to restore group '$GroupName'. Error: $_" -ForegroundColor Yellow
}
}
I have uploaded the PowerShell script to the my GitHub repository. You may access it from there for your further use.
Download : Restore-M365DeletedGroups
I trust that this article will significantly benefit you and your organization. I appreciate your patience in reading this post. I look forward to seeing you in the next post. Keep supporting the HTMD Community.
Need Further Assistance or Have Technical Questions?
Join the LinkedIn Page and Telegram group to get the latest step-by-step guides and news updates. Join our Meetup Page to participate in User group meetings. Also, Join the WhatsApp Community to get the latest news on Microsoft Technologies. We are there on Reddit as well.
Author
About the Author: Sujin Nelladath, a Microsoft Graph MVP with over 11 years of experience in SCCM device management and Automation solutions, writes and shares his experiences with Microsoft device management technologies, Azure, DevOps and PowerShell automation.