How to restore deleted Office 365 Groups
By default deleted Microsoft Office 365 groups are retained for 30 days. The groups which was deleted within 30 days are known as “soft-delete“, and can be restored using powershell.
Powershell can also be used to permanently delete these groups if an admin does not want to wait for the “soft-delete” retention period to expire.
IMPORTANT: If you use Remove-MsolGroup in PowerShell to delete a group, this will delete the group permanently. When using PowerShell to delete groups, it’s best practice to use Remove-AzureADMSGroup to soft-delete the O365 group. That way you can get it back if needed.
IMPORTANT: The procedures in this article require the PREVIEW version Azure Active Directory Module for Windows PowerShell, specifically, the AzureADPreview module, version 2.0.0.137 or later.
As a best practice, Microsoft recommends to always staying current: uninstall the old AzureADPreview version and get the latest one before you run PowerShell commands
To get started we need to download the latest version of AzureADPreview, this can be done using a normal powershell session.
To save the installer file run the below cmdlet.
1 |
Save-Module -Name AzureADPreview -Path c:\softlib\azure |
Next lets continue with installing the latest AzureADPreview PowerShell Module.
1 |
Install-Module -Name AzureADPreview |
If you have a previous version of the AzureADPreview installed use the below steps to uninstall and install the latest version.
- To uninstall a previous version of AzureADPreview, run this command:
1 |
Uninstall-Module AzureADPreview |
- To install the latest version of AzureADPreview, run this command:
1 |
Install-Module AzureADPreview |
- At the message about an untrusted repository, type Y. It will take a minute or so for the new module to install.
Now that we have the latest version of the AzureAD Powershell installed , lets continue with restoring a deleted Office 365 Group.
To restore a deleted group you must have Office 365 global admin or organization management permissions.
Lets create a connection to AzureAd powershell running the following cmdlet.
1 |
Connect-AzureAD |
Provide the login details of account with Global admin or Organization management permissions.
Run this command to display all soft-deleted Office 365 groups in your organization that are still within the 30 day retention period:
1 |
Get-AzureADMSDeletedGroup |
Here we can see the deleted group being displayed.
Note the ID of the groups as this will be used to restore the deleted group.
1 |
Restore-AzureADMSDeletedDirectoryObject –Id 0e3d6caf-6ae0-4a9a-ad62-2ff9ffb3e85d |
This process usually takes just a few minutes but in a few rare cases Microsoft has advised that it can take as long as 24 hours to completely restore.
Lets verify that the group has been successfully restored by running the following cmdlet:
1 |
Get-AzureADGroup –ObjectId 0e3d6caf-6ae0-4a9a-ad62-2ff9ffb3e85d |
The deleted group has been restored and is available in AzureAD again.
Once the restore has been completed, the group will reappear for the user in Outlook navigation pane and will contain the content of the group as well.
Group content that can be restored includes:
- Azure Active Directory (AD) Office 365 Groups object, properties and members
- Group SMTP address
- Exchange Online shared inbox and calendar
- SharePoint Online team site and files
- OneNote notebook
- Planner
Additionally if you have a connected Microsoft Team or Office 365 Connected Yammer group, those can be restored as well.
How to delete a group permanently
Sometimes you may want to permanently purge a group without waiting the 30 days for the soft-delete to expire. To do that start PowerShell and run this command to get the object ID of the group.
1 |
Get-AzureADMSDeletedGroup |
Take note of the object ID of the group, or groups, you want to permanently delete.
CAUTION: Purging the group removes the group and its data forever.
To purge the group run this command in PowerShell
1 |
Remove-AzureADMSDeletedDirectoryObject –Id 0e3d6caf-6ae0-4a9a-ad62-2ff9ffb3e85d |
To confirm that the group has been successfully purged, run the Get-AzureADMSDeletedGroup cmdlet again to confirm that the group no longer appears on the list of soft-deleted groups.
#ThatLazyAdmin
Be First to Comment