0

We have set up one Spam Filter policy in Exchange Online Protection with our allow and block sender and domain lists and we have created a second policy that we want to have the same allow and block lists.

Is there a way to basically copy or import/export the allow and block lists from one policy to the other using powershell?

2 Answers 2

0

It took a while to figure this out, but yes. Each list can be copied directly in a single command.

The trick was that you have to "walk" the objects returned using ForEach-Object. These four commands will copy all four allow/block lists:

Get-HostedContentFilterPolicy -Identity <source policy> | ForEach-Object {Set-HostedContentFilterPolicy -Identity <destination policy> -AllowedSenders $_.AllowedSenders}
Get-HostedContentFilterPolicy -Identity <source policy> | ForEach-Object {Set-HostedContentFilterPolicy -Identity <destination policy> -AllowedSenderDomains $_.AllowedSenderDomains}
Get-HostedContentFilterPolicy -Identity <source policy> | ForEach-Object {Set-HostedContentFilterPolicy -Identity <destination policy> -BlockedSenders $_.BlockedSenders}
Get-HostedContentFilterPolicy -Identity <source policy> | ForEach-Object {Set-HostedContentFilterPolicy -Identity <destination policy> -BlockedSenderDomains $_.BlockedSenderDomains}
0

Just in case anyone has the requirement to clone EOP allow/block lists and stumbled upon this post as I did.

Not sure if there is a change to the cmdlets, however, using array dot references to get the commands to work.

ie:$_.AllowedSenders.Sender

Get-HostedContentFilterPolicy -Identity <source policy> | ForEach-Object {Set-HostedContentFilterPolicy -Identity <destination policy> -AllowedSenders $_.AllowedSenders.Sender}
Get-HostedContentFilterPolicy -Identity <source policy> | ForEach-Object {Set-HostedContentFilterPolicy -Identity <destination policy> -AllowedSenderDomains $_.AllowedSenderDomains.Domain}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .