Another way you can add domains to a Whitelist in M365 is by using a script known as “PowerShell”.  To do this, follow these steps:

1. Make use of this specific script:

  1. Param(
  2. [Parameter(Mandatory=$True,Position=1)]
  3. [string]$ruleName,
  4. [Parameter(Mandatory=$True)]
  5. [string]$domainListFilePath
  6. )
  7. #Read the contents of the text file into an array
  8. $safeDomainList = Get-Content $domainListFilePath
  9. #Create a new array and remove all text for each line up to and including the @ symbol, also remove whitespace
  10. $newSafeDomainList = @()
  11. $newSafeDomainList += foreach ($domain in $safeDomainList)
  12. {
  13. $tmpdomain = $domain -replace “.*@”
  14. $tmpdomain.trim()
  15. }
  16. #If the rule already exists update the existing allowed sender domains, else create a new rule.
  17. if (Get-TransportRule $ruleName -EA SilentlyContinue)
  18. {
  19. “Updating existing rule…”
  20. $safeDomainList = Get-TransportRule $ruleName |select -ExpandProperty SenderDomainIs
  21. $completeList = $safeDomainList + $newSafeDomainList
  22. $completeList = $completeList | select -uniq | sort
  23. set-TransportRule $ruleName -SenderDomainIs $completeList
  24. }
  25. else
  26. {
  27. “Creating new rule…”
  28. $newSafeDomainList = $newSafeDomainList | sort
  29. New-TransportRule $ruleName -SenderDomainIs $newSafeDomainList -SetSCL “-1”
  30. }

2. Using the “Notepad” feature in Word, type in your domains to be listed as follows:

nicedomain.com
trusteddomain.com
tachytelic.net
testemailaddress@somedomain.com

3. Connect to the Exchange Online Portal using PowerShell. For instructions on how to do that, click on the below link:

https://docs.microsoft.com/en-us/powershell/exchange/connect-to-exchange-online-powershell?redirectedfrom=MSDN&view=exchange-ps

Run the script illustrated in Step #1 with these kinds of parameters:

.\Add365SafeDomains.ps1 -ruleName “Safe Domain List” -domainListFilePath “c:\domainlist.txt”

It is important to the note the following:

*If you are already using an existing rule, any duplicate domains are automatically purged;

*The domain list is thus sorted into an alphabetical order for easier reading in M365;

*If you a create a rule name that does not already exist, a new rule will thus be automatically created.