Recently had a request to limit the email attachment size for specific users within the Exchange Organization. The following one line script took care of the request:
New-TransportRule -Name 'Attachment Size Limit' -Comments '' -Priority '0' -Enabled $true -FromMemberOf 'AttachmentSizeLimit@Labnet.net' -SentToScope 'NotInOrganization' -AttachmentSizeOver '300 KB (307,200 bytes)' -RejectMessageReasonText 'Sorry, your attachment exceeds the limit of 300KB.' -RejectMessageEnhancedStatusCode '5.7.666'
Quick breakdown of the script:
1) I created a distribution group.
2) Added the required users to the group.
3) Did some quick research and decided on using the New-TransportRule cmdlet to achieve the objective.
4) Set the AttachmentSizeOver parameter to the requested value of 300KB, the SentToScope is set to NotInOrganization (only emails sent Outside the organization) and all other parameter values are set as indicated in the script.
You can also use the New-SystemMessage cmdlet to create new delivery service notifications. The following screen shot shows the result after testing the rule: