Listen to this Post
To block unwanted emails in Exchange Online, you can use PowerShell commands to manage mail flow rules and spam filters. Below are some practical commands and steps to achieve this:
1. Connect to Exchange Online PowerShell:
$UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection Import-PSSession $Session -DisableNameChecking
- Create a Mail Flow Rule to Block Specific Senders:
New-TransportRule -Name "Block Unwanted Sender" -SenderAddresses "[email protected]" -DeleteMessage $true
3. Block Emails from a Specific Domain:
New-TransportRule -Name "Block Unwanted Domain" -SenderDomainName "example.com" -DeleteMessage $true
- Increase Spam Confidence Level (SCL) for Specific Emails:
Set-HostedContentFilterPolicy -Identity Default -HighConfidenceSpamAction Quarantine -SpamAction Quarantine
5. Check Quarantined Emails:
Get-QuarantineMessage -RecipientAddress "[email protected]"
6. Release a Quarantined Email:
Release-QuarantineMessage -Identity <QuarantineMessageIdentity> -Confirm:$false
7. Block Attachments with Specific Extensions:
New-TransportRule -Name "Block Dangerous Attachments" -AttachmentExtensionMatchesWords @("exe", "bat", "js") -DeleteMessage $true
8. Disconnect from Exchange Online PowerShell:
Remove-PSSession $Session
What Undercode Say:
Blocking unwanted emails in Exchange Online is a critical task for maintaining a secure and efficient email environment. By leveraging PowerShell commands, administrators can create robust mail flow rules, manage spam filters, and block specific senders or domains effectively. The ability to quarantine high-confidence spam and dangerous attachments adds an extra layer of security. Regularly monitoring and managing quarantined emails ensures that legitimate emails are not mistakenly blocked. Additionally, automating these processes through scripts can save time and reduce human error. For further reading on Exchange Online management, refer to the official Microsoft documentation: Exchange Online PowerShell.
In conclusion, mastering these commands and techniques will significantly enhance your ability to control and secure your email environment, ensuring that only relevant and safe emails reach your inbox.
References:
initially reported by: https://www.linkedin.com/posts/ye-kyaw-tun-40b866225_blocking-unwanted-emails-in-exchange-online-activity-7295130610652614656-o6Rp – Hackers Feeds
Extra Hub:
Undercode AI


