Useful Exchange Powershell Commands ~ Setting Anti-Spam and Junk Settings

If you are using the native Exchange 2013 anti-spam settings, you may also want to configure how the users are handling their junk mail and what the thresholds are for sending messages to their Junk folders. Since none of this is found in the GUI anymore, it’s helpful to know the PowerShell commands.

What I typically do when setting up a new Exchange 2013 server that is going to handle its own anti-spam settings is to first enable the anti-spam components. I do that by running the install-antispamagents.ps1 script in the Scripts directory from an escalated Exchange PowerShell prompt.

Once that’s done, I run the following to set the basic SpamConfidenceLevel to 8 and to reject messages for the ContentFiltering agent:

Set-ContentFilterConfig -SCLRejectEnabled $True -SCLRejectThreshold 8


Because I want all users to have some control over their spam management, I enable all Junk folders and I set the SCL for those folders at a lower level than the global Content blocking SCL. I usually set it to 6.

Get-Mailbox | Set-Mailbox -SCLJunkEnabled $True -SCLJunkThreshold 6


If I want to configure the default Junk SCL threshold to 5 for the whole organization, I can use this script:

Set-OrganizationConfig -SCLJunkThreshold 5


Note that if I’ve configured a threshold directly on any specific user, the organizational level SCLJunkThreshold value will not apply, so it may be best only to enable all the users using the Get/Set command and then set the SCLJunkThreshold separately.

If I want to make one user (J.P. Morgan) an exception and have all mail to them completely bypass all filters, I can do this:

Set-Mailbox jpmorgan -AntiSpamBypassEnabled $True


Note that if I do this, local anti-spam settings in Outlook or the Junk mail settings will still apply. The user will just have a lot more stuff in his Junk mail folder.

Add your 2ยข