exchange-mailbox-cleanup

Walks operators through offboarding Exchange Online mailboxes with litigation hold and account deletion.

2|Updated Jul 28, 2026
One-click install
npx skills add https://github.com/mbadali25/useful-claude-add-ons --skill exchange-mailbox-cleanup-mbadali25
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: exchange-mailbox-cleanup
Source: https://github.com/mbadali25/useful-claude-add-ons/tree/main/skills/exchange-mailbox-cleanup
Command: npx skills add https://github.com/mbadali25/useful-claude-add-ons --skill exchange-mailbox-cleanup-mbadali25

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve? Offboarding a leaver's mailbox requires preserving email for seven years while freeing the licence seat, and doing it wrong (removing the licence instead of deleting the account) silently destroys the mailbox in 30 days. This Skill walks a non-technical operator through the entire Exchange Online mailbox cleanup runbook one step at a time, printing exact commands and verifying every result. ## Core Features & Use Cases - Guided 41-step runbook: Covers five phases from ServiceDesk Plus ticket creation and PowerShell module preflight through seven-year Litigation Hold application, account deletion (on-prem AD with Entra Connect delta sync or cloud-only Remove-MgUser), inactive-mailbox validation, and Purview eDiscovery export. - Operator-safe execution model: The Skill prints copy-pasteable Windows PowerShell 5.1 commands for the operator to run; it never runs Connect-ExchangeOnline or mutating cmdlets itself, and gates account deletion behind a typed confirmation. - Bundled helper scripts: Includes exo_preflight.ps1 for module/role checks and per-user installs, Resolve-OperatorInput.ps1 for normalizing a single address or CSV of leavers, and Read-ScriptLog.ps1 for decoding logs with correct encodings. - Use Case: HR confirms three leavers; the operator gives the Skill their addresses, and it drives the hold application, verifies preservation with item-count baselines, deletes the accounts after sign-off, and proves the mail is still searchable in Purview. ## Quick Start Ask the assistant to put a leaver's mailbox on litigation hold and delete their account, providing their email address or a CSV of leavers.

Frequently Asked Questions about exchange-mailbox-cleanup

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I offboard an Exchange Online mailbox for a terminated user?

Apply a seven-year Litigation Hold first, verify it stamped, then delete the account rather than removing the licence. Deleting the account under a hold converts the mailbox to an inactive mailbox that stays preserved and searchable while freeing the licence seat.

Why should I never remove the licence from a live mailbox?

Removing the licence soft-deletes the mailbox and Microsoft purges it after 30 days, even if a hold is in place. The seat must be freed by deleting the account while the hold is active, which preserves the mail as an inactive mailbox.

Does this work with PowerShell 7 or only Windows PowerShell 5.1?

The walkthrough targets Windows PowerShell 5.1 (PSEdition Desktop) only. ExchangeOnlineManagement 3.10.1 raised its PowerShell 7 floor to 7.6, and the ADSync module needed for the sync step has no PowerShell 7 build, so 5.1 is the only edition that works on both machines.

Why does my compliance search return zero items after granting eDiscovery Manager?

The eDiscovery Manager role takes 30 to 60 minutes to propagate to Microsoft's search back end, and until then every compliance search returns zero items with no error. The fix is waiting, not debugging; the walkthrough enforces this wait before running the baseline search.

Can this skill restore a mailbox or remove a litigation hold?

No, restoring mailboxes, removing holds, undeleting accounts, or destroying held mailboxes is handled by the separate exchange-mailbox-restore skill. This skill only performs the forward cleanup direction and refuses licence-removal requests.

What PowerShell modules are required for the mailbox cleanup runbook?

ExchangeOnlineManagement 3.9.0 or later plus four Microsoft Graph sub-modules (Authentication, Users, Users.Actions, Identity.DirectoryManagement) pinned to exactly 2.39.0. The bundled exo_preflight.ps1 -Install installs them per-user with no admin prompt after one confirmation.