How to Delete Office 365 Group using PowerShell?

Requirement: Delete Office 365 Group using PowerShell

How to Delete an Office 365 Group?

As an admin, you can delete Office 365 groups through Microsoft 365 admin center.

  • Log in to the Microsoft 365 Admin Center site:
  • Expand Groups and Click on Groups in the left navigation. 
  • Select the Office 365 group to delete. 
  • In the details pane, click on the “Delete” button and confirm the delete group in Office 365.
    how to delete office 365 group

Delete Office 365 Group using PowerShell

To delete Office 365 group using PowerShell, use Remove-UnifiedGroup cmdlet. Here is an example:

#Get Credentials to connect
$Credential = Get-Credential
#Create the session
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri `
           -Credential $Credential -Authentication Basic -AllowRedirection
#Import the session
Import-PSSession $Session -DisableNameChecking -AllowClobber

#Delete the Office 365 Group
Remove-UnifiedGroup -Identity "[email protected]" -confirm:$False

#Remove the session 
Remove-PSSession $Session

Please note, the Identity parameter takes Name, Display Name, Alias, Email Address, GUID, etc. Also, the Remove-UnifiedGroup cmdlet prompts for delete confirmation. Here we’ve suppressed it with -Confirm:$False switch.

When you delete an Office 365 group, you are permanently removing all resources of the group, including mailbox conversations, SharePoint site, notebook, and Planner tasks. If you deleted the group by mistake, you have 30 days to recover it! Let’s see how to hard delete Office 365 group using PowerShell.

How to Permanently Delete Office 365 Group using PowerShell?

To hard delete Office 365 group using PowerShell, use the following steps:

Pr-requisites: You need to have the Azure Active Directory Module installed! You can check if you have Azure AD module 2.0 installed by Get-InstalledModule. If you have previous versions of the module installed, You may have to uninstall using “Uninstall-Module AzureAD” and then install the latest version using “Install-Module AzureAD” cmdlet.

Here is how to permanently remove Office 365 Group using PowerShell: Assuming you have Office 365 global admin permissions, Open Windows PowerShell as Administrator.

  1. Connect to Azure AD by typing Connect-AzureAD cmdlet. This opens the Sign-In page for azure AD. Enter your credentials and Sign-in.
  2. Retrieve deleted groups using: Get-AzureADMSDeletedGroup cmdlet. This returns all deleted groups with their IDs.
  3. Now, you can permanently remove the deleted group using the group ID. E.g Remove-AzureADMSDeletedDirectoryObject -id 22bdc734-251f-48db-8030-19eb5560ddc3 
permanently delete office 365 group powershell

Salaudeen Rajack

Salaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

3 thoughts on “How to Delete Office 365 Group using PowerShell?

  • January 6, 2021 at 2:16 PM

    Can you then restore the SharePoint site without the O365 group?

  • December 8, 2020 at 10:46 AM

    helped me too, thanks 🙂

  • October 6, 2020 at 6:16 AM

    excellent explanation. it helped me a lot!! thanks!!


Leave a Reply