M365 Admin Handbook — Chapter 10: Microsoft Purview Compliance (Retention, Inactive Mailboxes, DLP & Audit Logs)

📚 Mastering Microsoft 365 & Endpoint Administration Chapter 10 of 14
View Full Book TOC →
📘 Chapter 10 Executive Brief — Purview Retention, Inactive Mailboxes, DLP & Audit Logs
  • Retention vs. Deletion: Purview Retention Policies (Exchange, SharePoint, OneDrive, Teams) always win over user deletion—moving purged items to the Recoverable Items\SubstrateHolds folder 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): UnifiedAuditLogIngestionEnabled is enabled by default in modern tenants; query Search-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

1. Retention Policies Exchange, SharePoint, OneDrive & Teams Chats SubstrateHolds / PHL Retain → Purge Safely 2. Inactive Mailboxes User Deleted / Unlicensed Hold Active → Preserved Zero License Required Recover or eDiscovery 3. Purview DLP SITs & Sensitivity Labels Simulation → Enforce Exchange / Teams / Endpoints Copilot Prompt Guardrails 4. Audit Logs Unified Audit Log 180d Std / 1yr+ E5 Search-UnifiedAuditLog Forensics & Alerts Golden Rule of Purview Precedence: Retention Wins Over Deletion → Shortest/Longest Hold Logic Applies Use Priority Cleanup only when legally approved to purge stale retention-locked data before Copilot grounds on it.

2. Purview Retention Policies & Labels

In Microsoft Purview Data Lifecycle Management (DLM), retention is governed by four principles:

  1. Retention wins over deletion (a user cannot permanently purge an item under an active hold).
  2. Longest retention period wins when multiple retention policies overlap.
  3. Explicit deletion wins over implicit retention only when a retention-and-delete period expires—unless an eDiscovery hold or Litigation Hold is still active.
  4. 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)

POWERSHELL
# 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)

POWERSHELL
# 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: Under MC1481313, legacy Teams retention policies targeting TeamsChannelLocation and TeamsChatLocation are 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

POWERSHELL
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

POWERSHELL
# 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

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.

POWERSHELL
# 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-AdminAuditLogConfig confirms UnifiedAuditLogIngestionEnabled : True and Get-OrganizationConfig shows AuditDisabled : 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

💬 Reader Comments & Feedback

Did this runbook help, or did Microsoft change a cmdlet or UI menu? Share your feedback below.