A project wrapped up in September, and the client’s IT lead wanted its Microsoft 365 group gone before a new team reused the same name. They’d already deleted it in the admin center, yet the alias was still taken and the group sat in Deleted groups.
That’s by design. Deleting a Microsoft 365 group only soft-deletes it for 30 days, so the name, email address and everything connected to it stay reserved. To really remove it you need a second step that purges it, and PowerShell is the quickest way to do both.
In this tutorial, we’ll walk through the force delete office 365 group powershell steps I use with PnP PowerShell: check the group, soft-delete it, purge it, restore one by mistake, do it all in one script, and the Microsoft Graph and Exchange Online equivalents.
Quick answer: Run Remove-PnPMicrosoft365Group -Identity <group id> to delete the group, then Remove-PnPDeletedMicrosoft365Group -Identity <group id> to purge it from deleted groups. The first command is a soft delete you can undo for 30 days; the second is the permanent “force” delete and can’t be undone.
What happens when you delete a Microsoft 365 group?
A Microsoft 365 group isn’t just a member list. It owns a mailbox, a SharePoint team site, a Planner plan and, if one was added, a team. My Microsoft Teams vs Microsoft 365 Groups comparison explains how those pieces fit together.
When you delete the group, Microsoft keeps it as a soft-deleted object for 30 days. During that window, a restore brings back all of this:
| Part of the group | Restored within 30 days? |
|---|---|
| Entra ID group object, properties and members | Yes |
| Group email addresses, shared inbox and calendar | Yes |
| SharePoint team site and its files | Yes |
| OneNote notebook and Planner | Yes |
| Microsoft Teams team (if the group had one) | Yes |
After 30 days, the group and its content are permanently deleted, and you can’t change that 30-day period. A purge simply skips the wait. Distribution groups are different: they don’t get a soft delete at all.
Check the group before you delete it
I use PnP PowerShell with my own Entra ID app registration. If PnP isn’t on your machine yet, follow this guide to install PnP PowerShell first, then connect:
Install-Module PnP.PowerShell -Scope CurrentUser
Connect-PnPOnline -Url "https://spguides.sharepoint.com/sites/SPGuides" -ClientId "<your-app-client-id>" -DeviceLogin -PersistLogin
Your app needs the Microsoft Graph permission Group.ReadWrite.All for every delete, purge and restore cmdlet in this post. Before I delete anything, I pull the group’s ID, privacy and site path, because that’s exactly what’s about to disappear:
$group = Get-PnPMicrosoft365Group -Identity "SPGDemo Old Project Group" -IncludeSiteUrl
[pscustomobject]@{
DisplayName = $group.DisplayName
Id = $group.Id
Alias = $group.MailNickname
Visibility = $group.Visibility
HasTeam = $group.HasTeam
SitePath = ([uri]$group.SiteUrl).AbsolutePath
} | Format-List

My demo group is private, has no team, and owns the site /sites/SPGDemoOldProjectGroup. Copy the Id: it’s the safest value to pass to every later command. On a real group, also export the owners and members first; this post on how to get Microsoft 365 group members with PowerShell has the script.
Delete a Microsoft 365 group with Remove-PnPMicrosoft365Group
Remove-PnPMicrosoft365Group takes one parameter, -Identity, which accepts the group’s ID, display name or a group object from the pipeline. I always pass the ID so a similar display name can’t catch the wrong group:
$group = Get-PnPMicrosoft365Group -Identity "SPGDemo Old Project Group"
# Soft delete: the group moves to deleted groups for 30 days
Remove-PnPMicrosoft365Group -Identity $group.Id
Start-Sleep -Seconds 15
$active = Get-PnPMicrosoft365Group | Where-Object Id -eq $group.Id
"Still an active group: $([bool]$active)"
Get-PnPDeletedMicrosoft365Group -Identity $group.Id |
Select-Object DisplayName, Id, DeletedDateTime | Format-List

There’s no confirmation prompt, so the command runs the moment you press Enter. Fifteen seconds later, the group was no longer active and showed up in deleted groups with its delete time:
Still an active group: False
DisplayName : SPGDemo Old Project Group
Id : 6b4c1140-a7bd-4c41-abc0-1eedead72dd9
DeletedDateTime : 11/1/2026 12:24:43 PM +00:00
At this point the group is only soft-deleted. You could still restore it, members, mailbox and site included, for 30 days.
Force delete the group permanently with Remove-PnPDeletedMicrosoft365Group
This is the step people mean by “force delete.” Remove-PnPDeletedMicrosoft365Group permanently removes a group that’s already in deleted groups. I look the group up by name in the deleted list, purge it by ID, then check that it’s gone:
$deleted = Get-PnPDeletedMicrosoft365Group |
Where-Object DisplayName -eq "SPGDemo Old Project Group"
$deleted | Select-Object DisplayName, Id, DeletedDateTime | Format-Table -AutoSize
# Force (permanent) delete: purge it from deleted groups - no restore after this
Remove-PnPDeletedMicrosoft365Group -Identity $deleted.Id
Start-Sleep -Seconds 10
$left = Get-PnPDeletedMicrosoft365Group | Where-Object Id -eq $deleted.Id
"Still in deleted groups: $([bool]$left)"

The output listed SPGDemo Old Project Group with its delete time, and after the purge it printed Still in deleted groups: False. That group can’t be restored anymore, and its alias is free to reuse.
Important: a purge works only on a soft-deleted group. If you run it against an active group, Microsoft Graph returns NotFound, which I show in the errors section below.
Restore a deleted group instead of purging it
Before you purge, make sure nobody needs the group. I deleted my second demo group, SPGDemo Purge Test, and then brought it back with Restore-PnPDeletedMicrosoft365Group:
$deleted = Get-PnPDeletedMicrosoft365Group |
Where-Object DisplayName -eq "SPGDemo Purge Test"
"Deleted on: $($deleted.DeletedDateTime)"
Restore-PnPDeletedMicrosoft365Group -Identity $deleted.Id | Out-Null
Start-Sleep -Seconds 20
Get-PnPMicrosoft365Group -Identity $deleted.Id |
Select-Object DisplayName, Id, Visibility | Format-List

Twenty seconds after the restore, Get-PnPMicrosoft365Group returned the group again with the same ID and Private visibility. Microsoft says a full restore of all the group’s data can take up to 24 hours, and you should wait at least an hour before you send email to a restored group.
Group owners can also restore their own group from Outlook on the web, and admins can use Groups > Deleted groups in the Microsoft 365 admin center.
Force delete a Microsoft 365 group in one script
Once you’re sure, you can run both steps together. The catch is timing: the group doesn’t show up in deleted groups instantly, so this script waits in a loop until it does, then purges it:
$name = "SPGDemo Purge Test"
$group = Get-PnPMicrosoft365Group -Identity $name
# Step 1: soft delete
Remove-PnPMicrosoft365Group -Identity $group.Id
"Soft-deleted: $name"
# Step 2: wait until it shows up in deleted groups, then purge it
do {
Start-Sleep -Seconds 5
$deleted = Get-PnPDeletedMicrosoft365Group | Where-Object Id -eq $group.Id
} until ($deleted)
Remove-PnPDeletedMicrosoft365Group -Identity $group.Id
"Purged: $name ($($group.Id)) - it can't be restored now"

It printed Soft-deleted: SPGDemo Purge Test and then the purge line with the group ID. I checked both lists afterward, and neither demo group was active or in deleted groups.
Pro Tip: keep a log of the ID and name of every group you purge. For more ready-made admin scripts, see my PnP PowerShell scripts for SharePoint developers.
Delete and purge a group with Microsoft Graph PowerShell
If your scripts already use the Microsoft Graph PowerShell SDK, the same two steps are Remove-MgGroup and Remove-MgDirectoryDeletedItem. Connect-MgGraph needs an interactive sign-in, so I’m showing this as code rather than a run:
Install-Module Microsoft.Graph -Scope CurrentUser
Connect-MgGraph -Scopes "Group.ReadWrite.All"
$group = Get-MgGroup -Filter "displayName eq 'SPGDemo Old Project Group'"
# Soft delete (restorable for 30 days)
Remove-MgGroup -GroupId $group.Id
# Find it in deleted items, then purge it
Get-MgDirectoryDeletedItemAsGroup -DirectoryObjectId $group.Id |
Select-Object DisplayName, Id, DeletedDateTime
Remove-MgDirectoryDeletedItem -DirectoryObjectId $group.Id
# Changed your mind before the purge? Restore it instead:
# Restore-MgDirectoryDeletedItem -DirectoryObjectId $group.Id
Remove-MgGroup moves Microsoft 365 and security groups to deleted items for 30 days. Remove-MgDirectoryDeletedItem then purges the object; per Microsoft Learn, it can’t be restored after that. Skip the retired AzureAD and MSOnline modules you’ll still find in older posts.
Delete a group with Exchange Online PowerShell
Exchange admins often reach for Remove-UnifiedGroup. It deletes the group, but it’s still a soft delete, so purge it afterward with PnP or Graph:
Install-Module ExchangeOnlineManagement -Scope CurrentUser
Connect-ExchangeOnline -UserPrincipalName admin@spguides.onmicrosoft.com
# -Confirm:$false skips the prompt; the group still goes to deleted groups for 30 days
Remove-UnifiedGroup -Identity "SPGDemo Old Project Group" -Confirm:$false
Remove-UnifiedGroup’s -Force switch only hides warnings and prompts; it doesn’t purge anything. Microsoft also notes that this cmdlet doesn’t work with certificate-based (app-only) sign-in or a managed identity, so unattended scripts should use Graph instead.
What about the group’s SharePoint site?
Deleting the group also deletes its team site, but a separate back-end job does that later. In my run, the SPGDemo Purge Test site moved to deleted sites about 10 minutes after its group was purged. The Old Project Group site, which I purged within a minute of deleting the group, was still active more than 30 minutes later.
So if you want SharePoint to clean up the site for you, give it some time between the soft delete and the purge. Check the site with Get-PnPTenantSite before you assume it’s gone.
When the site is left behind after the group is purged, delete it yourself from a SharePoint admin connection. This is what I ran on the leftover demo site 35 minutes after the purge:
Connect-PnPOnline -Url "https://spguides-admin.sharepoint.com" -ClientId "<your-app-client-id>" -DeviceLogin -PersistLogin
$url = "https://spguides.sharepoint.com/sites/SPGDemoOldProjectGroup"
$site = Get-PnPTenantSite -Url $url
"Template: $($site.Template) GroupId: $($site.GroupId)"
# The group is already purged, so the leftover site can be removed (it goes to deleted sites)
Remove-PnPTenantSite -Url $url -Force
It printed Template GROUP#0 with the old group ID, and Remove-PnPTenantSite moved the site to deleted sites, where it stays for 93 days like any deleted site.
Deleted SharePoint sites are kept for 93 days, while the other group resources are kept for only 30. Microsoft says that once those group resources are gone, you can permanently delete the leftover site with Remove-SPODeletedSite. My guide to deleting a SharePoint Online site with PowerShell covers those site cmdlets.
If a site complains that its group can’t be found, this fix for the Office 365 group connected to this site explains what happened. To see which sites are group-connected in the first place, get the SharePoint site owner with PowerShell.
When a compliance policy blocks the delete
Retention can stop you. Microsoft Purview documents that users get an error when they try to delete a site that’s subject to retention, and that includes a group’s team site. I walk through that exact message in a compliance policy is currently blocking this site deletion.
Before you force delete a group in a regulated tenant, ask your compliance admin which retention policies cover it. If you manage those policies yourself, my post on SharePoint site retention policies shows where they live. Sensitivity labels are a separate setting; here’s how to enable sensitivity labels for Microsoft 365 groups.
Common errors and how to fix them
I ran two mistakes on purpose: a typo in the group name, and a purge on a group that was still active:
# 1) A typo in the group name
try {
Remove-PnPMicrosoft365Group -Identity "SPGDemo Old Projects Group" -ErrorAction Stop
} catch { "Remove failed: $($_.Exception.Message)" }
# 2) Purging a group that is still active (not soft-deleted yet)
try {
$group = Get-PnPMicrosoft365Group -Identity "SPGDemo Old Project Group"
Remove-PnPDeletedMicrosoft365Group -Identity $group.Id -ErrorAction Stop
} catch { "Purge failed: $($_.Exception.Message)" }

- “Group not found”: the display name doesn’t match. Look up the exact name or, better, pass the group ID.
- “status code NotFound … does not exist” on a purge: the group isn’t soft-deleted yet. Run Remove-PnPMicrosoft365Group first, wait a few seconds, then purge.
- The deleted group isn’t listed yet: it can take a few seconds to appear in deleted groups. Use the wait loop from the one-script section.
- Access denied or 403: your app or account lacks Group.ReadWrite.All, or you aren’t an admin or owner. Only administrators can permanently delete a group.
- Connect-PnPOnline isn’t recognized: the module isn’t loaded. See this Connect-PnPOnline fix.
If you’re cleaning up more of a tenant with PowerShell, these guides pick up from here:
Frequently Asked Questions
How do I permanently delete a Microsoft 365 group with PowerShell?
Delete it with Remove-PnPMicrosoft365Group, then purge it with Remove-PnPDeletedMicrosoft365Group. The Remove-PnPDeletedMicrosoft365Group reference describes it as permanently removing a deleted group, so there’s no restore afterward.
How long is a deleted Microsoft 365 group kept?
30 days. Microsoft’s restore a deleted group guide says the group and its content are permanently deleted after that, and the period can’t be changed.
Does deleting a Microsoft 365 group delete the team and SharePoint site?
Yes. The team, mailbox, Planner plan and team site go with the group, and a restore within 30 days brings them back. The site itself can take a while to disappear from the tenant.
Does Remove-UnifiedGroup -Force purge the group?
No. -Force only suppresses prompts. The group still goes to deleted groups for 30 days, so purge it with Remove-PnPDeletedMicrosoft365Group or Remove-MgDirectoryDeletedItem.
Can I restore a group after I purge it?
No. Once a group is purged from deleted groups, it’s gone for good. Restore it with Restore-PnPDeletedMicrosoft365Group before you purge if there’s any doubt.

Hey! I’m Bijay Kumar, founder of SPGuides.com and a Microsoft Business Applications MVP (Power Automate, Power Apps). I launched this site in 2020 because I truly enjoy working with SharePoint, Power Platform, and SharePoint Framework (SPFx), and wanted to share that passion through step-by-step tutorials, guides, and training videos. My mission is to help you learn these technologies so you can utilize SharePoint, enhance productivity, and potentially build business solutions along the way.