Protection > Edit Anti-Spam Policy > Spam Action
This topic only applies to Exchange Online Protection (EOP) customers. Exchange Online customers do not need to run these commands.
The default anti-spam action for EOP customers is to move spam messages to the recipients’ Junk Email folder. In order for this action to work with on-premises mailboxes, you must configure two Exchange Transport rules on your on-premises Edge or Hub servers to detect spam headers added by EOP. These Transport rules will set the SCL used by the SclJunkThreshold property (of the Set-OrganizationConfig cmdlet) to move spam into the Junk Email folder of each mailbox. To add these transport rules, you must run the following cmdlets.
These steps assume that the SclJunkThreshold property (of the Set-OrganizationConfig cmdlet) has a value of 4. If this value is changed to a value above 6, such as 7 or 8, the SetScl value in the following cmdlets must be set to 9. For more information about how different SCL ratings are interpreted by the service, see Spam confidence levels.
Access the Exchange Management Shell for your on-premises Exchange server. For information about accessing and using the Shell with Exchange 2013, see Using PowerShell with Exchange 2013 (Exchange Management Shell).
Run the following command to route content-filtered spam to the Junk Email folder:
New-TransportRule "NameForRule" -HeaderContainsMessageHeader "X-Forefront-Antispam-Report" -HeaderContainsWords "SFV:SPM" -SetSCL 6
Run the following command to route messages marked as spam prior to reaching the content filter to the Junk Email folder:
New-TransportRule "NameForRule" -HeaderContainsMessageHeader "X-Forefront-Antispam-Report" -HeaderContainsWords "SFV:SKS" -SetSCL 6
If you do not want to use the Move message to Junk Email folder action, you may choose another action by editing your content filter policies in the Exchange admin center. For more information, see Configure your spam filter policies.