TOOLS · MICROSOFT PURVIEW

Custom sensitive information types, without writing regex.

Describe the identifier part by part and test it against real content. The builder then writes a rule package for Security & Compliance PowerShell. It runs in this tab: nothing you type or paste is uploaded or sent anywhere.

First, check whether Purview already has a built-in type

01Pattern

0 parts

    02What it matches

     

    03Sample content

    no sample

    04Test cases

    no cases

    Must match

      Must not match

        05Deliverables

        Rule package XML

         

        Microsoft asks for Unicode encoding; this downloads as UTF-16 LE with a byte order mark, the form Windows uses for it. Upload the file as it is.

        Upload & test

         

        06Checks

        no pattern

          07SIT settings

          To update an uploaded type, import your session file so the GUIDs stay the same, raise this by one, download again and upload with Set-DlpSensitiveInformationTypeRulePackage.

          Proximity counts characters either side of the match. Microsoft recommends 300 for a new custom type.

          A keyword must appear within the proximity window of the pattern match for the high-confidence rule to fire.

          08Deployment notes

          Keep it UTF-16. Microsoft says a rule package saved with any encoding other than Unicode won't work. Opening the XML in an editor and saving it as UTF-8 undoes the download.

          Raise the version to update. Microsoft 365 won't deploy a rule package uploaded again with the same version. Import your session file, raise Version in SIT settings, download, and upload with Set-DlpSensitiveInformationTypeRulePackage.

          Existing files need a recrawl. SharePoint and OneDrive content already stored is checked against a new type only after it is recrawled or rescanned.

          The GUIDs are paired. The schema requires the Resource idRef to equal the Entity id. Change one by hand and change the other.

          09Session

          Nothing is kept between visits by the builder. Export the session file to keep a build, and to update the same type later.

          Purview Pattern Builder · runs in this tab and sends nothing you enter anywhere. Patterns are previewed on the browser's regex engine. Purview evaluates them with Boost.RegEx 5.1.3, and the builder emits only constructs on which the two agree, apart from the preview fallback Checks reports.

          Check Microsoft’s built-in types first.

          Purview already detects the common Australian identifiers. Its built-in list covers tax file numbers, Australian Business Numbers, Australian Company Numbers, Medicare numbers (listed as Australia medical account number), passport and driver’s licence numbers, bank account numbers and physical addresses. Microsoft lists a checksum for the tax file number, ABN, ACN and Medicare formats.

          Build a custom type for identifiers your organisation issues itself: staff numbers, client and matter references, policy numbers, ticket and project codes. No built-in type knows their shape.

          What the rule package contains.

          One pattern, one capturing group
          The identifier sits inside the single capturing group Microsoft’s validation requires. Standalone matching adds fixed-width lookarounds at the edges so the pattern cannot fire inside a longer word or number. No ^ or $ is ever written: Microsoft says not to use them in a custom type. Upload runs Microsoft’s own validation; if it objects to the lookarounds, choose Anywhere, which leaves them out.
          Confidence
          Purview reads 85 as high, 75 as medium and 65 as low. With supporting keywords, the main rule fires only when one appears near the match. The optional second rule fires on the pattern alone at 65, so a policy can treat the two differently.
          Proximity
          Counted in Unicode characters either side of the match. In email, the message body and each attachment are separate items, so a keyword in the body does not support a match inside an attachment.
          GUIDs and names
          The rule pack, the publisher and the type each get a GUID. The type’s display name is filed under the type’s own GUID, a pairing the rule package schema requires.
          UTF-16
          The file downloads as UTF-16 little-endian with a byte order mark. Microsoft says to save a rule package with Unicode encoding, and that a rule saved any other way won’t work.
          Or skip the file
          The pattern from Copy pattern also works in the Purview portal: Information Protection, Classifiers, Sensitive info types, Create sensitive info type, with a regular expression as the primary element. Types made there go into Purview’s own Microsoft.SCCManaged.CustomRulePack rather than a package of their own, and need no PowerShell.

          From download to a tested type.

          1. PowerShell
            Connect-IPPSSession

            Connect to Security & Compliance PowerShell.

          2. PowerShell
            New-DlpSensitiveInformationTypeRulePackage

            Upload the downloaded file. The Upload & test panel above writes the command with the file name filled in.

          3. PowerShell
            Get-DlpSensitiveInformationType

            Confirm the type is listed. A custom type shows a publisher other than Microsoft Corporation: LensIQ, unless you changed it in SIT settings.

          4. PowerShell
            Test-DataClassification

            Try a string that should match. The command the builder writes names your type, so the result shows that type’s count and confidence.

          5. Sensitive info types › Test

            In the Microsoft Purview portal, open Information Protection, then Classifiers, then Sensitive info types. Select the type, choose Test and upload an unencrypted file that should match, then one that should not.

          The portal’s Test option is greyed out unless the tenant has at least one Exchange Online licence. Testing also needs a Purview role group, such as Compliance Administrator or Information Protection Admins, and an Exchange role, such as Data Loss Prevention.

          To change the type later, import your session file so the GUIDs stay the same, raise Version in SIT settings, download again and upload with Set-DlpSensitiveInformationTypeRulePackage. Microsoft 365 won’t deploy a rule package whose version hasn’t changed.

          Putting it to work in a DLP policy.

          A data loss prevention rule picks the type in its Content contains condition, with a confidence level and an instance count. Microsoft suggests stricter actions, such as blocking, for high-confidence matches and lighter ones, such as a notification, for low.

          Test the type everywhere you plan to use it. Microsoft notes the same type can return different results for email, for files in SharePoint and OneDrive, and on devices. Files already stored in SharePoint and OneDrive are checked against a new type only once they are recrawled, or rescanned with on-demand classification.

          Purview DLP Content contains condition with three SITs at Medium confidence
          Screenshot · Microsoft Learn A DLP rule’s Content contains condition, as Microsoft Learn shows it: each sensitive info type carries its own confidence level and instance count. A custom type joins the same list once it is uploaded. From Create a custom sensitive information type using PowerShell, Microsoft Learn.

          What Purview accepts in one custom type.

          Every limit on Microsoft Learn’s sensitive information type limits page, and what this builder does about each

          LimitValueWhat the builder does
          Regular expression length1,024 charactersChecks fail a longer pattern, counted on the exact expression the package carries, wrapping group included
          Capturing groups per expressionExactly 1Wraps the identifier in the one group; anything around it is (?: ). Checks fail none or several
          Distinct regexes per type20Writes one
          Term length in a keyword list50 charactersChecks fail a longer keyword
          Terms in a keyword list2,048Writes one keyword list per type; Checks fail more than 2,048
          Keyword dictionaries, combined, after compression1 MB (about 1,000,000 characters)Writes a keyword list, never a dictionary
          Rule package size150 KBChecks show the size of the file that downloads and fail one over 150 KB. A starter type is 2.6 to 3.8 KB; long keyword lists cross 150 KB at about 1,050 keywords of 50 characters
          Types per rule package50Writes one type per package
          Rule packages10Each download is a package of its own: uploading it as new uses one of the ten, updating it with Set-DlpSensitiveInformationTypeRulePackage keeps its place. So uploaded one per package, ten types fill every slot
          Custom types created in the Purview portal500Not counted here: this builder writes a rule package for PowerShell, not portal types. Microsoft asks for a support ticket above 500

          Where each statement comes from.

          Checked against Microsoft Learn ·

          1. Microsoft Learn Create a custom sensitive information type using PowerShell Rule package structure, confidence, proximity, version, upload and validation
          2. Microsoft Learn Sensitive information type limits The limits table
          3. Microsoft Learn Create custom sensitive information types Capturing group and anchor rules, the portal route, what Microsoft Support can help with
          4. Microsoft Learn Test sensitive information types Testing in the portal, and the roles it needs
          5. Microsoft Learn Learn about sensitive information types Exchange Online licence for Test, results by workload
          6. Microsoft Learn Sensitive information type entity definitions Built-in Australian types and their checksums
          7. Microsoft Learn Customize a built-in sensitive information type Unicode encoding
          8. Microsoft Learn Modify a custom sensitive information type using PowerShell Updating with Set-DlpSensitiveInformationTypeRulePackage
          9. Microsoft Learn Remove a custom sensitive information type using PowerShell Rolling back a rule package
          10. Microsoft Learn Step 1: Configure pattern-based sensitive data detection Proximity of 300 characters for a new custom type
          11. Microsoft Learn Test-DataClassification Testing a string from PowerShell
          12. Microsoft Learn Connect-IPPSSession Connecting to Security & Compliance PowerShell

          A tested pattern, built for your documents.

          Microsoft Support can’t help create custom classifications or regular expression patterns, and can’t assure that one meets your requirements. We build custom types and test them against the documents in your tenant.