Forum Discussion

techboy127's avatar
techboy127
Copper Contributor
Sep 01, 2026

Policy backup

Is it possible to backup the defender(custom antispam, anti phishing etc) policies. So they can be easily restored. As a disaster recovery mechanism or if I have to setup the tenant afresh. If yes what's the best method?

2 Replies

  • DerekMorgan2's avatar
    DerekMorgan2
    Brass Contributor

    Hi, techboy127​ - adding on to sateshbabulal1105​'s reply, Microsoft365DSC is my preferred option here. It exports Defender policies and the rest of your tenant as declarative files you can version and re-apply. Unattended runs need an app registration and certificate.

    Export-M365DSCConfiguration -Components @('EXOHostedContentFilterPolicy','EXOHostedContentFilterRule') -Path .\export

    Alternatively, build it on Azure Automation: a runbook using a managed identity pulls policies on a schedule and writes them to versioned Blob Storage.

    Exchange Online PowerShell:

    Get-HostedContentFilterPolicy | ConvertTo-Json -Depth 10

     

    Graph TCM snapshot (needs Entra P1; snapshots expire after 7 days, so copy them out): 

    POST /v1.0/admin/configurationManagement/configurationSnapshots/createSnapshot 

    Test a restore either way.

  • I export the polices with Graph API as a back-up, you should be able to update/create them the same way.