Office 365 - can I change default Junk Email behaviour for all users?

fieldj
fieldj used Ask the Experts™
on
Hi all,

We recently configured hybrid exchange and I am currently testing O365 with a few users.

I would like to change the Junk Email folder settings for all our of our users.  Is this possible?

This is the setting in Settings >> Mail >> Accounts >> Block or Allow

O365 junk email settings

I would like the default to be "Dont move email to my Junk Email folder".  It seems for the majority of users the default is "Automatically filter junk email".

I cannot seem to find anywhere in any of the admin consoles where I can pre-set this for our users.

Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2015
Distinguished Expert 2018

Commented:
You can use Set-MailboxJunkEmailConfiguration to configure this per-user.

Author

Commented:
Is there a way I can specify this for all users?  What about if I create a new user, would I have to remember to do this everytime?
Saif ShaikhServer engineer

Commented:
For all mailboxes you can connect to O365 powershell and run command: get-mailbox | set-MailboxJunkEmailConfiguration
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Saif ShaikhServer engineer

Commented:
$UserCredential = Get-Credential
 
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
 
Import-PSSession $Session

You can then test your connection by typing the command below. It will display mailbox information if you are connected:

Get-Mailbox

Now you are ready to make the change. The command below will turn off Junk Mail filtering for all users in the company. If there are service mailboxes in use that have never been logged into, you will see errors for those accounts when the change is attempted to be applied there. The script will then move on the the next mailbox until completion.

Get-Mailbox | Set-MailboxJunkEmailConfiguration –Enabled $False

Author

Commented:
Would I have to periodically repeat this task if I added new mailboxes?
Saif ShaikhServer engineer

Commented:
Yes you have to...

Author

Commented:
Ok, thanks.  I will give this a try and get back with my results.  Thanks for the help so far.

Author

Commented:
Thanks, I gave it a try and that seems to be working perfectly.

If I were to run this on a weekly scheduled task, is there a way I can (securely) store the O365 user credentials in the script?
Server engineer
Commented:
The below should work for all users..

$Domains = "contoso.com"
$users = get-mailbox -ResultSize "unlimited"

ForEach ($user in $users) {

$SetDomain = Get-MailboxJunkEmailConfiguration -Identity $user
$SetDomain.TrustedSendersAndDomains += $Domains
Set-MailboxJunkEmailConfiguration -Identity $user -TrustedSendersAndDomains $SetDomain.TrustedSendersAndDomains

}
MichelangeloSystem Administrator / Postmaster

Commented:
There arr Different ways to store credentials in a Script.
Have a look there for instance:
https://practical365.com/blog/saving-credentials-for-office-365-powershell-scripts-and-scheduled-tasks/

Author

Commented:
Thanks for the help

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial