What it is
A destructive PowerShell sample that reads Viva Engage community IDs from a CSV and deletes each community through the Microsoft Graph community API (beta endpoint) with app-only authentication. Deletion can't be undone. The script runs as a dry run by default ($whatIfMode = $true) and only deletes after you set it to $false.
Why use it
- Remove many communities in one run instead of deleting them one at a time.
- Preview the communities that would be deleted first;
$whatIfModeis$trueby default. - Continues past communities that aren't found and waits and retries when Graph throttles requests.
How to use it
- Create a Microsoft Entra app registration with the Microsoft Graph
Community.ReadWrite.Allapplication permission and grant admin consent. - Create a CSV with a single
CommunityIdcolumn containing the Graph community IDs (not the legacy numeric Yammer group IDs). - Set
$ClientId,$TenantId,$ClientSecret, and$groupsToBeDeletedCSVnear the top of the script. - Run with the default
$whatIfMode = $trueand review the output. Set it to$falseonly when you are sure. - Run:
.\Delete-EngageGroups.ps1Prerequisites
- Test in a non-production tenant first; deletion can't be undone
- Microsoft Entra app registration with the Community.ReadWrite.All application permission and admin consent
- CSV with a CommunityId column of Viva Engage community IDs from Microsoft Graph