How to export Data Loss Prevention (DLP) rule package for tenant?


I looked at the custom DLP config file in XML. This will allow to create Custom DLP rule. But I wanted to see if I can export all existing out of the box rules file in an XML. This will allow to study and create a custom new DLP Policy.

Step by step solution

Step # 1 Install and import the ExchangeOnlineManagement module in PowerShell

PS C:\DLPRules> Install-Module ExchangeOnlineManagement
PS C:\DLPRules> Import-Module ExchangeOnlineManagement

Step # 2 Connect to the portal with global admin user using Connect-IPPSSession

PS C:\DLPRules> Connect-IPPSSession
WARNING: Your connection has been redirected to the following URI:                                                      
";PSVersion=5.1.19 041.610"                                                                                                                PS C:\DLPRules> Get-DlpSensitiveInformationTypeRulePackage                                                              

Step # 3 List the Rule pack of the tenant

PS C:\DLPRules> Get-DlpSensitiveInformationTypeRulePackage
 Invariant Name         Localized Name         Publisher             Encrypted 
 --------------         --------------         ---------             --------- 
 Microsoft Rule Package Microsoft Rule Package Microsoft Corporation False     

Step # 4 Using the above localized name “Microsoft Rule Pacage” get package info

PS C:\DLPRules> $rulepak = Get-DlpSensitiveInformationTypeRulePackage -Identity "Microsoft Rule Package"

Step # 5 Now export the package info to an XML file

PS C:\DLPRules> Set-Content -Path "C:\DLPRules\ExportedRulePackage.xml" -Encoding Byte -Value $rulepak.SerializedClassificationRuleCollection

The file should be created now like the following.


PS C:\DLPRules> dir
 Directory: C:\DLPRules
 Mode                 LastWriteTime         Length Name
 ----                 -------------         ------ ----
 -a----         12/7/2020   2:23 PM        2041460 ExportedRulePackage.xml
 PS C:\DLPRules>

About Pankaj

I am a Developer and my linked profile is
This entry was posted in DLP. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s