Scripts · PowerShell

Delete-EngageGroups

Bulk-delete Viva Engage communities from a CSV through Microsoft Graph; dry run by default and deletion can't be undone.

View on GitHub

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; $whatIfMode is $true by default.
  • Continues past communities that aren't found and waits and retries when Graph throttles requests.

How to use it

  1. Create a Microsoft Entra app registration with the Microsoft Graph Community.ReadWrite.All application permission and grant admin consent.
  2. Create a CSV with a single CommunityId column containing the Graph community IDs (not the legacy numeric Yammer group IDs).
  3. Set $ClientId, $TenantId, $ClientSecret, and $groupsToBeDeletedCSV near the top of the script.
  4. Run with the default $whatIfMode = $true and review the output. Set it to $false only when you are sure.
  5. Run:
.\Delete-EngageGroups.ps1

Prerequisites

  • 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