Absolutely! Since you're already familiar with the concept of a Mail Flow Rule, the equivalent PowerShell method in Exchange Server 2019 uses the New-TransportRule and Set-TransportRule cmdlets.
This approach is faster for adding multiple domains or for bulk administration.
Whitelist a Domain using Exchange Management Shell (PowerShell)
The goal is the same as the Exchange Admin Center (EAC) method: create a Transport Rule that sets the Spam Confidence Level (SCL) to -1 for messages originating from the specified domain. An SCL of -1 means the message is considered safe and bypasses spam filtering.
1. Connect to Exchange Management Shell
Launch the Exchange Management Shell (EMS) on your Exchange 2019 server.
2. Create a New Transport Rule (Whitelist Rule)
Use the New-TransportRule cmdlet to create the whitelist rule. Replace "Trusted Domain Whitelist" with your desired rule name and "trusteddomain.com" with the actual domain you want to whitelist.
New-TransportRule -Name "Trusted Domain Whitelist" -Priority 0 -SenderDomainIs @("trusteddomain.com") -SetSCL -1 -StopProcessingRules $true
Parameter |
Description |
-Name |
A descriptive name for your rule. |
-Priority 0 |
Sets the rule to the highest priority (0 is the highest), ensuring it runs before any other filtering rules. |
-SenderDomainIs |
The condition: applies the rule if the sender's domain matches the one(s) specified. The domains are provided as a string array (@("domain1.com", "domain2.com")). |
-SetSCL -1 |
The action: sets the Spam Confidence Level to -1, which is the value for Bypass Spam Filtering. |
-StopProcessingRules $true |
(Recommended) Ensures that once this rule is matched, no further rules (including other spam filters) are applied to the message, which is necessary for a true whitelist. |
3. Adding a Domain to an Existing Rule
If you want to add a new domain to a whitelist rule you've already created (either via EAC or PowerShell), you need to retrieve the existing domains first, append the new one, and then update the rule.
- Define Variables for Rule Name and New Domain:
$RuleName = "Trusted Domain Whitelist"
$NewDomain = "anotherdomain.com"
- Get Existing Domains and Append the New One:
$CurrentDomains = (Get-TransportRule $RuleName).SenderDomainIs
$UpdatedDomains = $CurrentDomains + $NewDomain | Select-Object -Unique
- Update the Rule with the Full List:
Set-TransportRule $RuleName -SenderDomainIs $UpdatedDomains
4. Verification
To verify that your rule has been created and configured correctly, run:
Get-TransportRule "Trusted Domain Whitelist" | Format-List Name,State,Priority,Conditions,Actions
You should see the SenderDomainIs condition listing your domain(s) and the SetSCL action set to -1.
For further security best practices and to understand rule configuration in detail, this video can be helpful: How to set up email flow rules using PowerShell. This video walks through setting up mail flow rules in Exchange Online using PowerShell, which applies similar cmdlet concepts to your Exchange 2019 on-premises environment.
http://googleusercontent.com/youtube_content/2