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?

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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.