- Retention vs. Deletion: Purview Retention Policies (Exchange, SharePoint, OneDrive, Teams) always win over user deletion—moving purged items to the
Recoverable Items\SubstrateHoldsfolder and preserving departed users as Inactive Mailboxes at zero license cost. - DLP & AI Guardrails: Purview Data Loss Prevention (DLP) prevents sensitive data (PII, financials, labeled files) from leaking via email, Teams, endpoints, and Microsoft 365 Copilot—starting in Simulation Mode before enforcing blocks.
- Unified Audit Log (UAL):
UnifiedAuditLogIngestionEnabledis enabled by default in modern tenants; querySearch-UnifiedAuditLog(or Microsoft Graph Audit Log APIs) for forensic investigations and eDiscovery readiness.
In Chapter 9, we curbed collaboration sprawl across Microsoft Teams, SharePoint Online, and OneDrive. In Chapter 10, we lock down Microsoft Purview Compliance—ensuring your organization retains regulated records, preserves leaver mailboxes without wasting licenses, stops sensitive data exfiltration with DLP, and maintains a tamper-evident audit trail.
1. Architecture: How Purview Retention, Inactive Mailboxes & DLP Work Together
2. Purview Retention Policies & Labels
In Microsoft Purview Data Lifecycle Management (DLM), retention is governed by four principles:
- Retention wins over deletion (a user cannot permanently purge an item under an active hold).
- Longest retention period wins when multiple retention policies overlap.
- Explicit deletion wins over implicit retention only when a retention-and-delete period expires—unless an eDiscovery hold or Litigation Hold is still active.
- Adaptive Scopes dynamically target users, sites, or groups using Entra attributes (e.g.,
Department -eq "Finance") instead of static lists.
Connect to Security & Compliance PowerShell (Connect-IPPSSession)
# Interactive admin sign-in (or Certificate-Based Auth for unattended runbooks)
Connect-IPPSSession -UserPrincipalName admin@lab365.in -ShowBanner:$false
# Audit all existing Purview Retention Policies and Rules
Get-RetentionCompliancePolicy | Select-Object Name, Enabled, Mode, Workload, DistributionStatus | Format-Table -AutoSize
Get-RetentionComplianceRule | Select-Object Name, Policy, RetentionDuration, RetentionComplianceAction | Format-Table -AutoSize
Create a 7-Year Retention Policy (Exchange + SharePoint + OneDrive)
# 1. Create the policy scoped to Exchange, SharePoint, and OneDrive
New-RetentionCompliancePolicy -Name "Corp-7Year-Baseline-Retention" `
-ExchangeLocation All `
-SharePointLocation All `
-OneDriveLocation All `
-Enabled $true
# 2. Attach the 7-year (2555 days) Keep-Only rule
New-RetentionComplianceRule -Name "Corp-7Year-Baseline-Rule" `
-Policy "Corp-7Year-Baseline-Retention" `
-RetentionDuration 2555 `
-RetentionComplianceAction Keep
Legacy Teams Note: UnderMC1481313, legacy Teams retention policies targetingTeamsChannelLocationandTeamsChatLocationare consolidating into modern Purview DLM scopes. Also, if stale retention-locked files are polluting Copilot results, review Purview Priority Cleanup Hard Delete.
3. Inactive Mailboxes (Zero-License Leaver Preservation)
When an employee leaves, do not keep paying for an Exchange Online Plan 1/2 or M365 E3/E5 license just to preserve their mailbox—and do not convert every leaver into a Shared Mailbox unless active delegation is required.
Instead, apply a Purview Retention Policy or Litigation Hold before deleting the Entra user account. Once the Entra account is deleted (and purged after 30 days, or immediately), Exchange Online automatically converts the mailbox into an Inactive Mailbox—searchable via eDiscovery and consuming zero licenses.
For a complete deep dive, see Inactive Mailboxes in Exchange Online.
Live-Tested Exchange Online Inactive Mailbox Audit
Connect-ExchangeOnline -AppId "<AppId>" -CertificateThumbprint "<Thumbprint>" -Organization "xzf58.onmicrosoft.com" -ShowBanner:$false
# 1. List all Inactive Mailboxes and which hold is preserving them
Get-Mailbox -InactiveMailboxOnly -ResultSize Unlimited |
Select-Object DisplayName, UserPrincipalName, WhenSoftDeleted, LitigationHoldEnabled, InPlaceHolds |
Format-Table -AutoSize
# 2. Verify mailbox size of Inactive Mailboxes before eDiscovery or recovery
Get-Mailbox -InactiveMailboxOnly -ResultSize Unlimited | ForEach-Object {
$stats = Get-MailboxStatistics -Identity $_.DistinguishedName
[PSCustomObject]@{
DisplayName = $_.DisplayName
PrimarySmtp = $_.PrimarySmtpAddress
TotalItemSize = $stats.TotalItemSize
ItemCount = $stats.ItemCount
WhenSoftDeleted = $_.WhenSoftDeleted
}
} | Format-Table -AutoSize
Restore or Recover an Inactive Mailbox
# Option A: Restore the Inactive Mailbox to a brand-new active cloud mailbox
New-Mailbox -InactiveMailbox "<InactiveMailboxIdentity>" `
-Name "Restored-Leaver" `
-FirstName "Restored" `
-LastName "Leaver" `
-DisplayName "Restored Leaver" `
-MicrosoftOnlineServicesID "[email protected]" `
-Password (Read-Host -AsSecureString "Enter temporary password")
# Option B: Merge Inactive Mailbox contents into an existing manager's mailbox (into a subfolder)
New-MailboxRestoreRequest -SourceMailbox "<InactiveMailboxGuid>" `
-TargetMailbox "[email protected]" `
-TargetRootFolder "LeaverArchive" `
-AllowLegacyDNMismatch
4. Microsoft Purview Data Loss Prevention (DLP)
Purview DLP detects Sensitive Information Types (SITs) (credit cards, SSNs, IBANs, custom regex/EDMs) and Sensitivity Labels across Exchange Online, SharePoint, OneDrive, Teams, Endpoints, and Microsoft 365 Copilot.
Production Rollout Best Practice: Always deploy new DLP policies in Simulation Mode (TestWithoutNotifications / TestWithNotifications) for 14–30 days to measure false positives before switching to Enable (block with user override or hard block).
Audit & Deploy a Purview DLP Policy via PowerShell
# Audit existing DLP policies and their enforcement mode
Get-DlpCompliancePolicy | Select-Object Name, Mode, Enabled, Workload, DistributionStatus | Format-Table -AutoSize
# Create a DLP policy in Simulation Mode (Exchange + SharePoint + OneDrive + Teams)
New-DlpCompliancePolicy -Name "DLP-PII-Financials-Simulation" `
-ExchangeLocation All `
-SharePointLocation All `
-OneDriveLocation All `
-TeamsLocation All `
-Mode TestWithNotifications
# Add a rule detecting Credit Card Numbers or US SSNs shared externally
New-DlpComplianceRule -Name "Block-External-Financial-PII" `
-Policy "DLP-PII-Financials-Simulation" `
-ContentContainsSensitiveInformation @(
@{Name="Credit Card Number"; minCount=1},
@{Name="U.S. Social Security Number (SSN)"; minCount=1}
) `
-AccessScope NotInOrganization `
-BlockAccess $true `
-BlockAccessScope All `
-NotifyUser Owner, LastModifier `
-NotifyAllowOverride WithJustification
For scoping DLP specifically to Microsoft 365 Copilot and Administrative Units, see Purview DLP for M365 Copilot & Administrative Units.
5. Unified Audit Log (UAL) & Forensic Queries
Every admin change, mailbox access, SharePoint file download, Entra sign-in, and Copilot prompt (CopilotInteraction) flows into the Microsoft Purview Unified Audit Log. Standard M365 licenses retain audit records for 180 days; M365 E5 / Purview Audit (Premium) extends retention to 1 year (and up to 10 years with add-on).
For background on Exchange admin audit logging, see Admin Audit Logging in Exchange Online.
Live-Tested Audit Configuration Verification & Search
# 1. Verify Unified Audit Log ingestion is active in Exchange Online
Get-AdminAuditLogConfig | Select-Object UnifiedAuditLogIngestionEnabled, AdminAuditLogEnabled
Get-OrganizationConfig | Select-Object AuditDisabled
# 2. Query the last 7 days of mailbox permission changes & external sharing events
$Start = (Get-Date).AddDays(-7)
$End = Get-Date
Search-UnifiedAuditLog -StartDate $Start -EndDate $End `
-Operations "Add-MailboxPermission","Set-Mailbox","SharingSet","AnonymousLinkCreated" `
-ResultSize 500 |
Select-Object CreationDate, UserIds, Operations, AuditData |
Export-Csv "C:\Temp\M365_Audit_Last7Days.csv" -NoTypeInformation
Chapter 10 Verification Checklist
- [ ]
Get-AdminAuditLogConfigconfirmsUnifiedAuditLogIngestionEnabled : TrueandGet-OrganizationConfigshowsAuditDisabled : False. - [ ] Baseline Purview Retention Policy is active across Exchange, SharePoint, OneDrive, and Teams.
- [ ] Departed user offboarding runbook relies on Retention/Litigation Hold → Inactive Mailbox instead of keeping paid licenses assigned.
- [ ] All new Purview DLP rules start in Simulation Mode (
TestWithNotifications) and exclude break-glass/admin test noise before enforcement.
In Chapter 11, we will bridge on-premises and cloud messaging: Exchange Hybrid Coexistence (Entra Connect Sync, Exchange Server SE & the Dedicated Hybrid App).
References & Official Microsoft Documentation
- Learn about retention policies and retention labels | Microsoft Learn
- Learn about inactive mailboxes in Exchange Online | Microsoft Learn
- Learn about Microsoft Purview Data Loss Prevention | Microsoft Learn
- Search the audit log in Microsoft Purview | Microsoft Learn
- Connect-IPPSSession (ExchangePowerShell) | Microsoft Learn
💬 Reader Comments & Feedback
Did this runbook help, or did Microsoft change a cmdlet or UI menu? Share your feedback below.
Leave a Comment or Report an Update