NexlinksField Notes from a CTO & CISO
Menu
Practical perspectives on Microsoft technology. Read the November 2026 newsletter ↗

PRACTITIONER ARTICLE / Security

Building Your First Microsoft Purview DLP Policy: From Detection to Enforcement

Build a Microsoft Purview DLP policy using sensitivity labels and a custom classifier. Test Exchange, SharePoint and OneDrive in simulation before enforcement.

Published
By Phil Kinsley
In this article

Microsoft Purview Technical Series | Part 3

Build the pilot DLP policy in simulation mode first. Confirm that either the Confidential label or the custom customer-reference SIT produces the intended match, then test external restrictions in Exchange, SharePoint and OneDrive before broadening the scope.

Finding sensitive information is useful, but it doesn't prevent that information from being shared.

In Part 1, we configured a Confidential sensitivity label and tested how SharePoint permissions and encryption affect document access and Microsoft 365 Copilot retrieval.

In Part 2, we created a custom Sensitive Information Type (SIT) to identify customer references, examined classification results, and extended discovery to on-premises file shares.

We now have two ways of identifying information that needs protection: a sensitivity label assigned to a document and a classifier that recognizes sensitive content whether or not somebody has labeled it.

The header-only label from our pilot and the custom SIT do not themselves restrict external sharing. Encryption on a label can impose access restrictions, depending on its configuration.

This is where Microsoft Purview Data Loss Prevention (DLP) becomes relevant. DLP evaluates supported content and activities against defined conditions, then applies actions such as notifying users, restricting external access, or blocking email delivery.

For this article, we'll extend the same pilot to Exchange Online, SharePoint Online and OneDrive for Business. We'll create a policy that uses the Confidential label from Part 1 and the customer-reference SIT from Part 2, test it in simulation mode, examine exceptions and determine when enforcement is appropriate.

The objective is to establish whether the policy detects the intended information and applies the intended restriction without interrupting legitimate business activity.

Define What the Policy Needs to Prevent

Before opening the policy wizard, establish what the rule needs to accomplish.

For our pilot, the requirement is straightforward:

Prevent information classified as Confidential, or containing our custom customer reference, from being shared outside the organization through Exchange Online, SharePoint or OneDrive.

Internal collaboration should continue unless an existing permission or protection setting prevents it.

We're going to use one DLP policy with two alternative detection conditions:

  • The content contains a high-confidence match for Nexlinks Customer Reference.
  • The content has the Confidential sensitivity label.

The detection conditions will be combined using OR, while the external-sharing condition will be combined with that group using AND.

Conceptually, the rule is:

IF
    Content is shared outside the organization
AND
    (
        Content contains Nexlinks Customer Reference
        OR
        Content has the Confidential sensitivity label
    )

THEN
    Restrict external access
    Notify the user
    Record the DLP activity

This allows us to test two different protection scenarios.

A document can trigger the policy because somebody correctly classified it, even if it contains no recognizable sensitive information.

Alternatively, an unlabeled document can trigger the same policy because its contents match the custom SIT.

That's the relationship between classification and DLP we want to demonstrate.

What about licensing?

Microsoft 365 E3 includes core Purview DLP for Exchange Online, SharePoint Online and OneDrive for Business.

You don't need E5 to create this basic content-based DLP policy or enforce the supported external-sharing restrictions.

Microsoft 365 E5 and qualifying Purview add-ons provide additional capabilities, including Endpoint DLP, Teams chat DLP, advanced Outlook policy tips and controls specific to Microsoft 365 Copilot.

The licensing requirements are feature-specific. The policy we're building doesn't require Endpoint DLP or the advanced Copilot DLP location.

Confirm the Existing Configuration

Before creating another DLP policy, check what is already deployed.

Some tenants have a Microsoft-created default Office 365 DLP policy that detects credit card numbers in externally shared content.

That policy may already be enforcing restrictions.

If our test fails because another policy blocked an action, we need to distinguish that from the behavior of the policy we're about to create.

Navigate to:

Microsoft Purview > Data loss prevention > Policies

Review the existing policies, their deployment states, selected locations and rules.

You can also retrieve the configuration using Security & Compliance PowerShell.

Import-Module ExchangeOnlineManagement

Connect-IPPSSession `
    -UserPrincipalName "<your-admin-UPN>"

List the DLP policies:

Get-DlpCompliancePolicy |
    Format-Table Name, Mode -AutoSize

For a particular policy:

Get-DlpCompliancePolicy `
    -Identity "Policy Name" |
    Format-List *

Retrieve its rules:

Get-DlpComplianceRule `
    -Policy "Policy Name" |
    Format-List *

This provides a useful baseline for comparing existing controls with the proposed configuration.

The cmdlets are different from the Get-Label and Get-LabelPolicy commands used in Part 1. Sensitivity labeling policies and DLP policies serve different purposes, even when both reference the same sensitivity label.

You'll need an account with appropriate DLP administrative permissions. Microsoft supports roles such as Information Protection Admin and Compliance Administrator for policy management.

Prepare the Existing Test Documents

We're keeping the same documents used earlier in the series.

Prepare the Existing Test Documents
DocumentExisting configuration
Purview-Pilot-Canary-2026.docxConfidential label, header only, no encryption
Purview-Pilot-Discovery-2026.docxContains Customer Reference: NXL-2026-000123, initially unlabeled


The first document allows us to test label-based detection.

The second allows us to test content-based detection using the custom SIT.

Both remain in the SharePoint pilot site established previously.

For OneDrive, copy the discovery document to a dedicated pilot user's OneDrive account. Keep that copy unlabeled so we can test content detection independently.

For Exchange, prepare a new email containing:

Subject: Purview DLP Pilot

Customer Reference: NXL-2026-000123

This message contains synthetic information
for Microsoft Purview DLP testing.

Use controlled test accounts and recipients. Don't send real customer information or live financial identifiers.

We're also going to need an approved external test account to validate the difference between internal and external sharing.

Before using it, confirm that external sharing is permitted at the appropriate SharePoint tenant and site levels. Otherwise, SharePoint may prevent the activity before DLP becomes involved, making the result inconclusive.

Create the DLP Policy

Navigate to:

Microsoft Purview > Data loss prevention > Policies > Create policy

Select Enterprise applications & devices, followed by the Custom category and template.

Use the following name:

Nexlinks-DLP-External-Pilot

For the description, enter:

*Detect Confidential content or Nexlinks customer references in Exchange Online, SharePoint and OneDrive, and restrict external sharing.*

Configure the locations

Select:

  • Exchange email
  • SharePoint sites
  • OneDrive accounts

Leave other locations disabled.

The location configuration matters because DLP doesn't interpret every policy condition identically across workloads.

Exchange evaluates messages being sent. SharePoint and OneDrive evaluate supported files stored in those services, including relevant sharing activity.

For the pilot, restrict the scope rather than selecting every mailbox, site and OneDrive account.

Use the existing SharePoint test site, the pilot OneDrive account and an appropriate mail-enabled security group containing the Exchange test sender.

The same group used for sensitivity label publishing isn't necessarily suitable for Exchange DLP scoping. Exchange group-based DLP evaluation has specific group-type and membership requirements, so verify those before using a group in the policy.

OneDrive is scoped by the relevant accounts, while SharePoint is scoped by site location.

Don't assume excluding a user from an Exchange rule also excludes documents that user can access through SharePoint.

Create the rule

Select Create or customize advanced DLP rules.

Create a rule named:

Restrict External Sharing - Confidential or Customer Reference

Add the first condition:

Content is shared from Microsoft 365 > With people outside my organization

Add a second condition group containing the two alternatives:

Content contains > Sensitive info types > Nexlinks Customer Reference

Set the SIT configuration to require at least one instance at the high-confidence level established in Part 2.

Add the second alternative:

Content contains > Sensitivity labels > Confidential

Configure the condition groups so that external sharing must be true and either the SIT or sensitivity-label condition is satisfied.

Pay attention to the Boolean operators. If the conditions are incorrectly joined using AND, the rule could require a document to contain the customer reference and have the Confidential label before it matches.

Microsoft Purview condition summary combining external sharing with sensitive information types or a sensitivity label.
Source: Microsoft Learn. Microsoft Learn example of condition grouping. Its classifiers differ from this pilot; use Nexlinks Customer Reference and the Confidential label in your rule.

Microsoft Learn: external-sharing policy example

Configure the action

Under Actions, select:

Restrict access or encrypt the content in Microsoft 365 locations

Choose:

Block users from receiving email or accessing shared SharePoint and OneDrive files

Then select:

Block only people outside your organization

This is deliberately narrower than Block everyone.

For SharePoint and OneDrive, internal users can continue accessing the file according to their existing permissions, while external access is restricted.

In Exchange, the behavior is different. When external recipients trigger the blocking rule, Outlook policy tips can prevent the message from being sent until those external recipients are removed, including when the message also contains internal recipients.

Don't assume Exchange will simply deliver the message to internal recipients while silently removing external recipients.

Configure notifications

Enable user notifications and policy tips.

For the pilot, use a description such as:

*This content contains information that your organization restricts from external sharing. Review the classification or contact the information owner before proceeding.*

Keep the message specific. Users need to understand what was prevented and what action they should take.

Under incident reports, enable appropriate administrator alerts and select the required severity.

For a small pilot, alerts for every match may be useful. In production, generating an alert for every matching document can create unnecessary volume, particularly when the policy evaluates existing SharePoint and OneDrive content.

Microsoft Purview user notification settings, including email notifications and policy tips.
Source: Microsoft Learn. Microsoft Learn example of notification settings. Review these choices for the pilot; the selected options shown here are Microsoft’s example configuration.

Microsoft Learn: user notifications and policy tips

Leave user overrides disabled initially.

Complete the wizard, but don't enable enforcement yet.

Run the Policy in Simulation Mode

At the final deployment step, select:

Run the policy in simulation mode

Leave Show policy tips while in simulation mode disabled for the first pass.

Also leave the option to automatically turn the policy on after fifteen days disabled. We want an explicit decision before enforcement begins.

Simulation mode evaluates policy conditions and records matches without applying the configured blocking action.

This allows administrators to establish what the policy would affect before changing access or disrupting email delivery.

Simulation behaves differently across workloads

Microsoft documents an important difference in what gets evaluated.

Run the Policy in Simulation Mode
LocationSimulation behavior
Exchange OnlineEvaluates new messages sent during simulation
SharePoint OnlineEvaluates existing and new or modified content
OneDrive for BusinessEvaluates existing and new or modified content


If you enable simulation and search for an email sent last week, don't expect it to appear simply because it contains the custom SIT.

Send a new test message after the policy is active.

SharePoint and OneDrive are different. Simulation can process existing content, which means a policy scoped too broadly may report substantially more matches than expected.

Microsoft documents that simulations can run for up to fifteen days, with simulation data retained for thirty days.

Don't treat the results as a permanent historical record.

Review the simulation

Navigate to:

Data loss prevention > Policies

Select the pilot policy and choose View simulation.

The simulation experience provides:

  • A summary of scanning progress and matched items.
  • Items for review, including available item metadata.
  • Alerts associated with the simulated policy.

Use the results to establish whether the intended documents and messages matched.

Microsoft limits the SharePoint and OneDrive Items for review display to 100 matched items per site, per rule. The displayed list may therefore contain fewer items than the reported total.

For larger deployments, don't assume the visible list represents every match.

Test Exchange, SharePoint and OneDrive Separately

Although we're using one policy, each workload needs its own test.

The detection conditions are shared, but the user experience and enforcement behavior are not identical.

Exchange Online

Send two messages from the pilot sender.

The first should contain the customer reference and be addressed to an internal recipient.

The second should contain the same reference and be addressed to a controlled external recipient.

Expected behavior:

  • The internal-only message should not satisfy the external-sharing condition.
  • The external message should match the policy and appear in the simulation results after processing.

Repeat the test with a message that doesn't contain the customer reference but includes an attachment labeled Confidential.

Because the pilot label from Part 1 was scoped to files rather than email messages, the attachment is the relevant labeled content for this test.

Once enforcement is enabled, the external message should be blocked according to the rule's configured action.

Use the actual Exchange Online message trace and DLP activity to confirm the outcome.

A policy tip alone is not evidence that the message was blocked.

SharePoint Online

Use Purview-Pilot-Canary-2026.docx, which already has the Confidential label.

It doesn't need to contain the custom customer reference because the label provides the second detection path.

Review whether it appears in the simulation results.

Next, use the unlabeled Purview-Pilot-Discovery-2026.docx.

This document should satisfy the custom SIT condition.

For the sharing test, use an approved external test account and attempt to grant access through SharePoint.

The important distinction is that SharePoint DLP can apply external-access restrictions proactively to sensitive files, even before somebody explicitly shares them externally.

Once enforced, the configured action may prevent external access as soon as the sensitive file has been processed.

That means an attempt to share the document externally may fail without generating the incident notification you expected from a sharing event.

Microsoft documents this behavior, including suppression of some alerts when proactive blocking occurs, so validate the restriction itself rather than using alert counts as the only measure of success.

OneDrive for Business

Repeat the test using the unlabeled copy of the discovery document stored in the pilot OneDrive account.

Keep the same custom SIT and external-sharing condition.

Verify that the policy includes the correct OneDrive account and that the file contains the expected customer reference.

The anticipated outcome is similar to SharePoint: the policy should identify the content and, when enforced, restrict external access without removing legitimate internal access.

A policy match in SharePoint doesn't establish that OneDrive is configured correctly. Verify both locations independently.

Check the Results Against the Expected Behavior

Record expected and observed results separately.

Check the Results Against the Expected Behavior
TestExpected result
Exchange: internal recipient, matching SITNo external-sharing rule match
Exchange: external recipient, matching SITPolicy match; delivery blocked when enforced
Exchange: external recipient, Confidential attachmentPolicy match, subject to supported label detection
SharePoint: Confidential documentLabel condition satisfied; external access restricted when enforced
SharePoint: unlabeled document with customer referenceSIT condition satisfied; external access restricted when enforced
OneDrive: unlabeled document with customer referenceSIT condition satisfied; external access restricted when enforced
Document with invalid customer reference and no Confidential labelNo match


These are expected outcomes based on the configured policy, not completed test results.

For each execution, record the account, file or message, classification, recipient or sharing target, policy mode, timestamp, and actual response.

If a result doesn't match expectations, establish whether the issue is detection, location scoping, policy propagation, or enforcement.

For example, the custom SIT may work in its standalone test but fail to match an Exchange attachment. That requires investigating the attachment's supported format, extraction and detection conditions rather than immediately changing the DLP action.

Inspect the deployed policy with PowerShell

After creating the policy, confirm that Purview has the intended configuration.

Get-DlpCompliancePolicy `
    -Identity "Nexlinks-DLP-External-Pilot" |
    Format-List Name, Mode, DistributionStatus

Inspect the rule:

Get-DlpComplianceRule `
    -Policy "Nexlinks-DLP-External-Pilot" |
    Format-List *

You can retrieve additional deployment details with:

Get-DlpCompliancePolicy `
    -Identity "Nexlinks-DLP-External-Pilot" `
    -DistributionDetail |
    Format-List DistributionStatus

These commands help validate what has been configured and whether the policy has distributed successfully.

They don't replace an end-to-end test of the user action.

Microsoft also provides Test-DlpPolicies for evaluating individual SharePoint and OneDrive items, but the cmdlet only supports policies scoped exclusively to those locations and simple conditions.

It isn't suitable for this combined Exchange, SharePoint and OneDrive policy with grouped Boolean conditions.

For our exercise, use the simulation results and workload-specific tests instead.

Introduce Policy Tips Before Enforcement

Once the initial simulation produces the expected matches, enable:

Show policy tips while in simulation mode

Keep the policy scoped to the pilot users and locations.

The purpose is to understand how users experience the proposed control before allowing it to block their work.

For Exchange, test the message in Outlook and review the displayed policy tip.

For SharePoint and OneDrive, inspect the document's policy information and any notifications.

The exact user experience varies between Outlook clients, Office applications and SharePoint or OneDrive.

Policy tips also depend on supported conditions, client versions and licensing. Don't assume that a tip appearing correctly in Outlook on the web establishes that the same behavior is available in every Outlook desktop version.

User overrides

Purview supports policy overrides for certain blocking actions.

For example, an organization might allow a user to override a restriction after providing a business justification.

That may be appropriate when external sharing is legitimate but needs to be documented.

However, an override is not simply a notification acknowledgment. It allows the user to bypass the configured blocking action under the permitted conditions.

For this pilot, retain the non-overridable restriction.

If the business later requires overrides, introduce them in a separate test and validate the user experience, justification capture and resulting audit evidence.

Understand the Difference Between Exceptions and Exclusions

Exceptions are one of the more important parts of DLP policy design.

They can also undermine a policy when they're introduced without understanding their scope.

There are three mechanisms to distinguish.

Location exclusions

You can exclude specific locations or accounts from a policy.

For example, you might exclude an approved migration SharePoint site while testing another site.

However, this removes the excluded site from the policy's evaluation scope.

It doesn't mean that only approved migration activity is exempt.

If somebody places unrelated sensitive documents in that site, they may also fall outside the policy.

Use location exclusions only where the entire location is intended to be excluded.

Rule-level exceptions

Rule exceptions apply when defined conditions are met.

For Exchange, an organization might have an approved process allowing a specific department to send sensitive information to a named external recipient.

Microsoft supports nested Boolean conditions that can express an exception requiring both the sender and recipient to match the approved relationship.

The important word is both.

An exception that excludes every message sent by a department would be considerably broader.

If you need sender- or recipient-specific conditions, create and validate an Exchange-specific rule or policy rather than assuming those conditions behave identically in SharePoint and OneDrive.

User overrides

An override allows an authorized user to proceed despite a policy match.

Unlike a location exclusion, the policy still detects the content, and the override can generate evidence explaining why the restriction was bypassed.

This may be useful for legitimate business exceptions, but it shouldn't be treated as equivalent to a formal approval workflow unless the organization has implemented and validated one.

For the initial pilot, I prefer avoiding exceptions entirely.

Establish the baseline detection and blocking behavior first. Introduce exceptions only when there is a documented business requirement that can be tested.

Moving from Simulation to Enforcement

Once the policy has produced the expected results and legitimate business scenarios have been reviewed, the next step is enforcement.

Before making that change, confirm:

  1. The required content matches the rule.
  2. Negative test cases don't generate unintended matches.
  3. Internal collaboration remains possible.
  4. External sharing is restricted as intended.
  5. Pilot users understand the notifications and escalation process.
  6. Existing policies don't introduce conflicting behavior.

Then return to:

Data loss prevention > Policies > Nexlinks-DLP-External-Pilot

Change the policy deployment state to:

Turn it on right away

Keep the initial enforcement scope limited to the pilot accounts and locations.

Validate enforcement directly

Repeat the Exchange, SharePoint and OneDrive tests.

For Exchange, confirm that the external message cannot be sent or delivered according to the configured action.

For SharePoint and OneDrive, test direct external access to the document using the approved external account.

Don't rely on the absence or presence of a sharing link alone. Attempt to open the file.

Also verify that the intended internal users can still access it.

DLP restrictions can be applied asynchronously in SharePoint and OneDrive. Allow time for policy distribution and content processing, and don't interpret a brief propagation delay as proof that enforcement will never occur.

Monitor the policy

After enforcement, review the DLP Alerts dashboard, Activity Explorer where licensed, and the relevant Microsoft 365 audit evidence.

Look for unexpected blocks, false positives and business processes that depend on the restricted activity.

An enforcement policy that blocks legitimate collaboration requires attention, even when the sensitive information detection itself is correct.

If you need to change a production rule, consider testing a revised copy in simulation before replacing the existing policy.

Don't assume that editing a live policy provides the same protection against unintended changes as simulation.

What This Policy Doesn't Protect

Our policy now controls a defined external-sharing scenario across Exchange, SharePoint and OneDrive.

That doesn't make it a comprehensive data loss prevention deployment.

It doesn't prevent every form of internal oversharing. We deliberately chose to restrict external access. A document that is broadly accessible internally may still be visible to more employees than intended.

It doesn't automatically protect information stored on endpoints. Endpoint DLP is a separate capability with additional licensing and device prerequisites.

It doesn't automatically enforce restrictions on on-premises file servers. The scanner from Part 2 uses a separate DLP configuration and enforcement model for on-premises repositories.

It doesn't classify every sensitive document. The custom SIT detects the customer-reference format we configured. Business-sensitive information without recognizable patterns may not match.

It doesn't automatically prevent Copilot from using internally accessible content. The Exchange, SharePoint and OneDrive DLP policy we're building restricts specified sharing activities. It is not the same as a Copilot-specific DLP policy that prevents selected labeled files from being processed as grounding content.

That distinction takes us back to the original reason for this series.

A document can be protected against external sharing while remaining accessible to internal users through broad SharePoint permissions.

If those users are licensed for work-grounded Microsoft 365 Copilot, the document may still be available for retrieval, subject to its permissions, encryption and applicable Copilot-specific controls.

DLP helps protect information within the scope of its rules. It doesn't eliminate the need to understand who can access the underlying content.

Before moving to enforcement

The important result isn't that a policy exists in Purview. It's whether the conditions identify the correct content, whether the intended action is applied, and whether legitimate business activity can continue.

Simulation gives us an opportunity to establish those facts before enforcement. It also helps identify gaps in classification, unexpected matches and policy conditions that are too broad.

Once the control is validated, enforcement becomes a deliberate operational decision rather than an assumption that the configuration is correct.

In the planned Part 4, we'll return to Microsoft 365 Copilot and SharePoint oversharing. We'll examine how existing access permissions, sensitivity labels and DLP interact, and why restricting external sharing doesn't necessarily prevent sensitive information from being retrieved by AI.

That will build on the same test documents and permission scenarios rather than starting another isolated configuration exercise.

Primary source

Microsoft DLP policy deployment guidance ↗

Further sources

Microsoft Purview DLP overview ↗

Create and deploy a DLP policy ↗

DLP policy conditions, actions and locations ↗

DLP simulation mode ↗

Configure and review DLP simulation ↗

Prevent external sharing from SharePoint and OneDrive ↗

Exchange DLP conditions and actions ↗

DLP notifications, policy tips and overrides ↗

Test your DLP policies ↗

Microsoft Purview licensing ↗

Continue reading

Finding Sensitive Data with Microsoft Purview: From Microsoft 365 to On-Premises File Servers ↗

Getting Started with Microsoft Purview: Classify Your Data Before Copilot ↗