Do not use without appropriate Microsoft 365 E5, E5 Compliance, or E5 Information Protection licensing. Do not deploy DLP policies directly to production enforcement mode without a simulation period. Do not configure endpoint DLP without coordinating with the endpoint management team responsible for device onboarding.
Define the classification hierarchy that maps to organizational data handling requirements:
Public -> No protection, external sharing allowed
General -> No encryption, internal watermark "GENERAL"
Confidential -> Encryption (all employees), header/footer marking
├─ Confidential - All Employees
├─ Confidential - Finance
└─ Confidential - HR
Highly Confidential -> Encryption (specific users/groups), watermark, no forwarding
├─ Highly Confidential - Project X
└─ Highly Confidential - Board Only
# Connect to Security & Compliance PowerShell
Connect-IPPSSession -UserPrincipalName admin@contoso.com
# Create parent label
New-Label -DisplayName "Confidential" `
-Name "Confidential" `
-Tooltip "Business data that could cause damage if disclosed to unauthorized parties" `
-Comment "Apply to internal business documents, financial reports, and customer data"
# Create sub-label with encryption
New-Label -DisplayName "Confidential - Finance" `
-Name "Confidential-Finance" `
-ParentId (Get-Label -Identity "Confidential").Guid `
-Tooltip "Financial data restricted to Finance department" `
-EncryptionEnabled $true `
-EncryptionProtectionType "Template" `
-EncryptionRightsDefinitions "finance-group@contoso.com:VIEW,VIEWRIGHTSDATA,DOCEDIT,EDIT,PRINT,EXTRACT,OBJMODEL" `
-ContentType "File, Email"
Set-Label -Identity "Confidential-Finance" `
-HeaderEnabled $true `
-HeaderText "CONFIDENTIAL - FINANCE" `
-HeaderFontSize 10 `
-HeaderFontColor "#FF0000" `
-HeaderAlignment "Center" `
-FooterEnabled $true `
-FooterText "This document contains confidential financial information" `
-WatermarkEnabled $true `
-WatermarkText "CONFIDENTIAL" `
-WatermarkFontSize 36
New-LabelPolicy -Name "Corporate Label Policy" `
-Labels "Public","General","Confidential","Confidential-Finance",
"Confidential-HR","HighlyConfidential","HighlyConfidential-ProjectX" `
-ExchangeLocation "All" `
-ModernGroupLocation "All" `
-Comment "Standard corporate sensitivity labels"
# Require justification for label downgrade
Set-LabelPolicy -Identity "Corporate Label Policy" `
-AdvancedSettings @{RequireDowngradeJustification="True";
DefaultLabelId="General"}
Configure DLP policies that detect and protect sensitive content across Microsoft 365 workloads:
# Create DLP policy scoped to Exchange, SharePoint, OneDrive
New-DlpCompliancePolicy -Name "Financial Data Protection" `
-ExchangeLocation "All" `
-SharePointLocation "All" `
-OneDriveLocation "All" `
-TeamsLocation "All" `
-Mode "TestWithNotifications" `
-Comment "Protects credit card numbers, bank account numbers, and financial identifiers"
# Create rule for high-volume credit card detection
New-DlpComplianceRule -Name "Block Bulk Credit Card Sharing" `
-Policy "Financial Data Protection" `
-ContentContainsSensitiveInformation @{
Name = "Credit Card Number";
MinCount = 5;
MinConfidence = 85
} `
-BlockAccess $true `
-BlockAccessScope "All" `
-NotifyUser "SiteAdmin","LastModifier" `
-NotifyUserType "NotSet" `
-GenerateIncidentReport "SiteAdmin" `
-IncidentReportContent "All" `
-ReportSeverityLevel "High"
# Create rule for low-volume with user override
New-DlpComplianceRule -Name "Warn on Credit Card Sharing" `
-Policy "Financial Data Protection" `
-ContentContainsSensitiveInformation @{
Name = "Credit Card Number";
MinCount = 1;
MaxCount = 4;
MinConfidence = 75
} `
-NotifyUser "LastModifier" `
-NotifyUserType "NotSet" `
-GenerateAlert "Low" `
-NotifyOverride "WithJustification"
# Create custom SIT for employee ID format (EMP-XXXXXX)
$rulePackXml = @"
<RulePackage xmlns="http://schemas.microsoft.com/office/2011/mce">
<RulePack id="$(New-Guid)">
<Version major="1" minor="0" build="0" revision="0"/>
<Publisher id="$(New-Guid)"/>
</RulePack>
<Rules>
<Entity id="$(New-Guid)" patternsProximity="300"
recommendedConfidence="85">
<Pattern confidenceLevel="85">
<IdMatch idRef="EmployeeId_Regex"/>
</Pattern>
<Pattern confidenceLevel="95">
<IdMatch idRef="EmployeeId_Regex"/>
<Match idRef="EmployeeId_Keyword"/>
</Pattern>
</Entity>
<Regex id="EmployeeId_Regex">EMP-[0-9]{6}</Regex>
<Keyword id="EmployeeId_Keyword">
<Group matchStyle="word">
<Term>employee</Term>
<Term>employee id</Term>
<Term>emp id</Term>
<Term>staff number</Term>
</Group>
</Keyword>
<LocalizedStrings>
<Resource idRef="EmployeeId_Regex">
<Name default="true" langcode="en-us">Contoso Employee ID</Name>
<Description default="true" langcode="en-us">
Detects Contoso employee IDs in format EMP-XXXXXX
</Description>
</Resource>
</LocalizedStrings>
</Rules>
</RulePackage>
"@
# Save and import the rule package
$rulePackXml | Out-File -FilePath "EmployeeID_SIT.xml" -Encoding utf8
New-DlpSensitiveInformationTypeRulePackage -FileData (
[System.IO.File]::ReadAllBytes("EmployeeID_SIT.xml")
)
New-DlpCompliancePolicy -Name "Highly Confidential Sharing Control" `
-ExchangeLocation "All" `
-SharePointLocation "All" `
-OneDriveLocation "All" `
-Mode "Enable"
New-DlpComplianceRule -Name "Block External Sharing of HC Content" `
-Policy "Highly Confidential Sharing Control" `
-ContentContainsSensitiveInformation $null `
-ContentPropertyContainsWords "MSIP_Label_$(
(Get-Label -Identity 'HighlyConfidential').Guid
)_Enabled=True" `
-BlockAccess $true `
-BlockAccessScope "NotInOrganization" `
-NotifyUser "LastModifier" `
-GenerateIncidentReport "SiteAdmin" `
-ReportSeverityLevel "High"
Extend DLP protection to managed Windows and macOS endpoints to control file operations:
# Check onboarding status via Intune Graph API
# GET https://graph.microsoft.com/beta/deviceManagement/managedDevices
# Filter for complianceState and dlpOnboardingStatus
# Local verification on Windows endpoint
# Check registry key:
# HKLM\SOFTWARE\Microsoft\Windows Advanced Threat Protection\Status
# OnboardingState should be 1
# Configure unallowed apps (browsers, cloud sync clients)
Set-PolicyConfig -EndpointDlpGlobalSettings `
-UnallowedApps @(
@{Name="Chrome"; Executable="chrome.exe"},
@{Name="Firefox"; Executable="firefox.exe"},
@{Name="PersonalDropbox"; Executable="Dropbox.exe"}
)
# Configure unallowed Bluetooth apps
Set-PolicyConfig -EndpointDlpGlobalSettings `
-UnallowedBluetoothApps @(
@{Name="BluetoothFileTransfer"; Executable="fsquirt.exe"}
)
# Configure network share groups
Set-PolicyConfig -EndpointDlpGlobalSettings `
-NetworkShareGroups @(
@{
Name = "Authorized Shares";
NetworkPaths = @("\\server01\approved$", "\\server02\secure$")
}
)
# Configure sensitive service domains (allowed cloud destinations)
Set-PolicyConfig -EndpointDlpGlobalSettings `
-SensitiveServiceDomains @(
@{
Name = "Approved Cloud Storage";
Domains = @("sharepoint.com", "onedrive.com")
MatchType = "Allow"
},
@{
Name = "Blocked Cloud Storage";
Domains = @("dropbox.com", "box.com", "drive.google.com")
MatchType = "Block"
}
)
# Add endpoint location to existing policy
Set-DlpCompliancePolicy -Identity "Financial Data Protection" `
-EndpointDlpLocation "All"
# Create endpoint-specific rule
New-DlpComplianceRule -Name "Block USB Copy of Financial Data" `
-Policy "Financial Data Protection" `
-ContentContainsSensitiveInformation @{
Name = "Credit Card Number";
MinCount = 1;
MinConfidence = 85
} `
-EndpointDlpRestrictions @(
@{Setting="CopyToRemovableMedia"; Value="Block"},
@{Setting="CopyToNetworkShare"; Value="Audit"},
@{Setting="CopyToClipboard"; Value="Block"},
@{Setting="Print"; Value="Warn"},
@{Setting="UploadToCloudService"; Value="Block"},
@{Setting="UnallowedBluetoothApp"; Value="Block"}
) `
-NotifyUser "LastModifier" `
-GenerateIncidentReport "SiteAdmin"
# Define authorized USB devices by vendor/product ID
Set-PolicyConfig -EndpointDlpGlobalSettings `
-RemovableMediaGroups @(
@{
Name = "Approved Encrypted USBs";
Devices = @(
@{VendorId="0781"; ProductId="5583"; SerialNumber="*"} # SanDisk Extreme
)
}
)
# Define authorized printers
Set-PolicyConfig -EndpointDlpGlobalSettings `
-PrinterGroups @(
@{
Name = "Corporate Printers";
Printers = @(
@{PrinterName="*Corporate*"; PrinterType="Corporate"},
@{PrinterName="PDF Printer"; PrinterType="Print to PDF"}
)
}
)
Deploy service-side auto-labeling to automatically classify content at rest and in transit:
New-AutoSensitivityLabelPolicy -Name "Auto-Label Financial Emails" `
-ExchangeLocation "All" `
-Mode "TestWithNotifications" `
-Comment "Automatically labels emails containing financial data as Confidential-Finance"
New-AutoSensitivityLabelRule -Name "Financial SIT Match" `
-Policy "Auto-Label Financial Emails" `
-SensitiveInformationType @{
Name = "Credit Card Number";
MinCount = 1;
MinConfidence = 85
},@{
Name = "U.S. Bank Account Number";
MinCount = 1;
MinConfidence = 85
} `
-WorkloadDomain "Exchange" `
-ApplySensitivityLabel "Confidential-Finance"
New-AutoSensitivityLabelPolicy -Name "Auto-Label SP Financial Docs" `
-SharePointLocation "https://contoso.sharepoint.com/sites/finance" `
-OneDriveLocation "All" `
-Mode "TestWithNotifications"
New-AutoSensitivityLabelRule -Name "Financial Docs SIT Match" `
-Policy "Auto-Label SP Financial Docs" `
-SensitiveInformationType @{
Name = "Credit Card Number"; MinCount = 1; MinConfidence = 85
} `
-WorkloadDomain "SharePoint" `
-ApplySensitivityLabel "Confidential-Finance"
# Check simulation results
Get-AutoSensitivityLabelPolicy -Identity "Auto-Label Financial Emails" |
Select-Object Name, Mode, WhenCreated, DistributionStatus
# Switch to enforcement after validation
Set-AutoSensitivityLabelPolicy -Identity "Auto-Label Financial Emails" `
-Mode "Enable"
Use Activity Explorer and the DLP alerts dashboard to monitor policy effectiveness and investigate incidents:
Activity Explorer filter:
Activity type = DLPRuleMatch
Action = Override
Date range = Last 30 days
Policy name = Financial Data Protection
Export to CSV for analysis of override justifications and
affected file types to refine SIT confidence thresholds.
# DLP alerts are configured within the DLP rule itself
# Adjust alert volume thresholds on high-traffic rules
Set-DlpComplianceRule -Identity "Block Bulk Credit Card Sharing" `
-GenerateAlert "High" `
-AlertProperties @{
AggregationType = "SimpleAggregation";
Threshold = 1;
TimeWindow = "00:05:00"
}
import requests
# Authenticate with Microsoft Graph (client credentials flow)
token_url = "https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token"
token_response = requests.post(token_url, data={
"client_id": client_id,
"client_secret": client_secret,
"scope": "https://graph.microsoft.com/.default",
"grant_type": "client_credentials"
})
access_token = token_response.json()["access_token"]
headers = {"Authorization": f"Bearer {access_token}"}
# Retrieve DLP alerts
alerts_url = "https://graph.microsoft.com/v1.0/security/alerts_v2"
params = {
"$filter": "serviceSource eq 'microsoftDataLossPrevention'",
"$top": 50,
"$orderby": "createdDateTime desc"
}
response = requests.get(alerts_url, headers=headers, params=params)
alerts = response.json().get("value", [])
for alert in alerts:
print(f"Alert: {alert['title']}")
print(f" Severity: {alert['severity']}")
print(f" Status: {alert['status']}")
print(f" Created: {alert['createdDateTime']}")
print(f" User: {alert.get('userStates', [{}])[0].get('userPrincipalName', 'N/A')}")
# Search unified audit log for DLP policy matches
Search-UnifiedAuditLog -StartDate (Get-Date).AddDays(-7) `
-EndDate (Get-Date) `
-RecordType "DLP" `
-ResultSize 1000 |
Select-Object CreationDate, UserIds, Operations,
@{N='PolicyName';E={($_.AuditData | ConvertFrom-Json).PolicyDetails.PolicyName}},
@{N='RuleName';E={($_.AuditData | ConvertFrom-Json).PolicyDetails.Rules.RuleName}},
@{N='SITMatched';E={($_.AuditData | ConvertFrom-Json).SensitiveInfoDetections.SensitiveType}} |
Export-Csv -Path "DLP_Audit_Report.csv" -NoTypeInformation
| Term | Definition |
|---|---|
| Sensitivity Label | A classification tag applied to documents and emails that can enforce encryption, content marking (headers/footers/watermarks), and access restrictions. Labels persist with the content and travel with files when shared externally. |
| Sensitive Information Type (SIT) | A pattern-based classifier that detects specific data patterns (credit card numbers, SSNs, custom regex) in content. Each SIT has a confidence level (low/medium/high) determined by primary pattern match plus corroborating evidence (keywords, proximity). |
| DLP Policy | A set of rules that detect sensitive information in Microsoft 365 locations (Exchange, SharePoint, OneDrive, Teams, Endpoints) and apply protective actions (audit, warn with override, block) based on the sensitivity of matched content and the sharing context. |
| Endpoint DLP | Extension of DLP protection to managed Windows and macOS devices that monitors and controls file operations including copy-to-USB, print, upload-to-cloud, copy-to-clipboard, and access by unallowed applications for files containing sensitive information. |
| Activity Explorer | A monitoring dashboard in Microsoft Purview that displays a historical view (up to 30 days) of labeled content activities, DLP policy matches, and user interactions with classified data across all monitored locations. |
| Auto-Labeling | Service-side automatic classification that applies sensitivity labels to documents and emails matching specified SIT patterns without requiring user interaction. Runs in simulation mode first to preview matches before enforcement. |
| Content Marking | Visual indicators (headers, footers, watermarks) applied by sensitivity labels to documents and emails. Markings persist in the file and are visible when printed or shared, serving as a visual classification reminder. |
| DLP Alert | A notification generated when a DLP rule match meets the configured severity threshold. Alerts appear in the Microsoft Purview DLP alerts dashboard and can be routed to Microsoft Sentinel or other SIEM platforms. |
Context: A financial services company with 15,000 users across 12 countries needs to prevent credit card numbers, bank account details, and financial statements from being shared externally through email, Teams, SharePoint, and endpoint file operations. The company must comply with PCI-DSS and GDPR.
Approach:
Pitfalls:
Context: A pharmaceutical company needs to prevent research data identified by internal project codes (format: RX-YYYY-NNNN) and compound identifiers from being shared outside the research department. The data appears in lab reports, research presentations, and email communications.
Approach:
RX-20[2-3][0-9]-[0-9]{4} with corroborating keywords ("compound", "trial", "formulation", "assay", "efficacy") within 300-character proximity. Set primary pattern at 85% confidence and keyword-corroborated pattern at 95%.CPD-[A-Z]{3}-[0-9]{5} with keywords ("molecule", "synthesis", "pharmacokinetics") for higher confidence matching.RX-202[4-6]-[0-9]{4} to target only active project codes and reduce false positives by 60%.Pitfalls:
## DLP Policy Deployment Report
**Policy Name**: PCI-DSS Financial Data Protection
**Deployment Date**: 2026-03-19
**Current Mode**: Simulation (TestWithNotifications)
**Locations**: Exchange Online, SharePoint Online, OneDrive, Teams, Endpoints
---
### Simulation Results (14-Day Period)
**Total Policy Matches**: 4,287
**Unique Users Affected**: 892
**Unique Files/Messages**: 3,641
| Rule | Matches | Action | Override Rate |
|------|---------|--------|---------------|
| Block Bulk Credit Card Sharing (5+) | 47 | Block | N/A |
| Warn on Credit Card Sharing (1-4) | 4,240 | Warn | 12.3% |
### Sensitive Information Type Breakdown
| SIT | Matches | Avg Confidence | False Positive Est. |
|-----|---------|----------------|---------------------|
| Credit Card Number | 3,891 | 87% | 8.2% |
| U.S. Bank Account Number | 312 | 82% | 15.1% |
| ABA Routing Number | 84 | 79% | 22.6% |
### Recommendations
1. **Enable enforcement** for "Block Bulk Credit Card Sharing" rule -
47 matches are all true positives involving bulk credit card data in
spreadsheet attachments.
2. **Increase confidence threshold** for ABA Routing Number from 75 to 85 -
22.6% false positive rate driven by 9-digit numbers in invoice references
matching the routing number pattern.
3. **Add file type exception** for password-protected ZIP attachments that
trigger false positives when the credit card SIT matches encrypted content
metadata.
4. **Deploy endpoint DLP** in audit mode for 7 additional days before
enabling block actions on USB copy and cloud upload.
---
### DLP Alert Summary (Last 7 Days)
| Severity | Count | Top Policy | Top User |
|----------|-------|------------|----------|
| High | 12 | Financial Data Protection | j.smith@contoso.com |
| Medium | 89 | IP Protection - Research | r.chen@contoso.com |
| Low | 234 | General PII Protection | (distributed) |
### Activity Explorer Insights
- Peak DLP match activity: Monday 09:00-11:00 UTC (weekly report distribution)
- Top matched location: Finance SharePoint site (62% of all matches)
- Most overridden rule: "Warn on Credit Card Sharing" (523 overrides, 12.3%)
- Override justification analysis: 78% "Business requirement", 15% "False positive",
7% "Other"