How to Delete Office 365 Group using PowerShell?

Requirement: Delete Office 365 Group using PowerShell

How to Delete  Office 365 Group?
As an admin, you can delete office 365 groups through Microsoft 365 admin center.
  • Login 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 "Delete" button and confirm 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 "" -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 a 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 following steps:

Pr-requisites: You need to have 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 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
How to Delete Office 365 Group using PowerShell? How to Delete Office 365 Group using PowerShell? Reviewed by Salaudeen Rajack on April 22, 2018 Rating: 5

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.