I hope you have a text files with SPAM white and black lists. If so, it’s all down to run the PowerShell command after connecting to Exchange Online.
If you created custom SPAM filter policy, replace “default” in Identity property with your custom filter policy name in the commands below.
Create different text files for Allowed and Blocked email addresses. Also create different text files for allowed and blocked email domain names.
The first line should be “Recipients” in all the text files.
Add bulk add SPAM White List (email addresses)
Import-Csv “C:\..\AllowedEmails.csv” | foreach {Set-HostedContentFilterPolicy -Identity Default -AllowedSenders @{add=$_.Recipients}}
Add bulk add SPAM Block List (email addresses)
Import-Csv “C:\..\BlockedEmails.csv” | foreach {Set-HostedContentFilterPolicy -Identity Default –BlockedSenders @{add=$_.Recipients}}
Add bulk add SPAM White List (email domains)
Import-Csv “C:\..\AllowedDomains.csv” | foreach {Set-HostedContentFilterPolicy -Identity Default –AllowedSenderDomains @{add=$_.Recipients}}
Add bulk add SPAM Block List (email addresses)
Import-Csv “C:\..\BlockedEmails.csv” | foreach {Set-HostedContentFilterPolicy -Identity Default –BlockedSenderDomains @{add=$_.Recipients}}
I hope it saved you sometime on your research. Leave me a reply if it did.
Definitely save me time! Just might have to “Enable-OrganizationCustomization” before you run. But it will say so if you need to do it.
Skype has opened its web-structured client beta to the entire world, soon after introducing it broadly from the
U.S. and U.K. earlier this calendar month.
Skype for Website also now works with Chromebook and Linux
for instant messaging conversation (no video and voice yet, these call for a connect-in installation).
The increase from the beta provides help for a longer set of languages to
help you bolster that international usability
Thank you!!
Just what I was looking for, thanks.
Hello
In the CSV file what should separate the domain names?
It’s comma.
Thank you, so regarding the CSV file. I have typed “recipients” in cell A1 and the domain names in cell A2. Each domain name is separated by a “,”. So for example test.com,test1.com
Is this correct. Also will it over write any allow domain that are already added previously? I.e will it append the new CSV list of domain names to what’s already configured? Also will powershell error if my new list of domains has a duplicate domain name to what’s already configured in the allow domain names.
Thanks 🙂
Hello
Got it working but, i cant seem to use a comma. My cvs looks like the below and works and apends
“recipients”
domain1.com
domain2.com
domain3.com
Any idea how to have the domains on one line? comma isnt working
Big THANK YOU for taking the time to do this!!
Thanks … When I put it in a script and call it from powershell session, I get the error:
A positional parameter cannot be found that accepts argument ‘â€BlockedSenders @{add=@{Recipients=123@345.com}.SpamEmailAddresses}}
The script is like:
# Blocks Spammers – Email Address & Domains if required
$Spammers = “E:\scripts\Repository\Exchange-Online\Blocked-Email-Address.csv”
$SpamDomains = “E:\scripts\Repository\Exchange-Online\Blocked-Domains.csv”
$SpamPolicy = ‘Custom-BlockList-For-AntiSPAM’
# Block Senders
Import-Csv $Spammers | foreach {Set-HostedContentFilterPolicy -Identity $SpamPolicy –BlockedSenders @{add=$_.SpamEmailAddresses}}
# Block Domains
Import-Csv $SpamDomains | foreach {Set-HostedContentFilterPolicy -Identity $SpamPolicy –BlockedSenderDomains @{add=$_.SpamDomains}}
# End of Script
The file E:\scripts\Repository\Exchange-Online\Blocked-Email-Address.csv has:
SpamEmailAddresses
Ryan@gotrenchless.com
However when the commands are run individually in powershell, it works!
yes, it helped me. Thanks a lot