We are importing emails from CSV to add in bulk to block with Transport rules.
If the module is not installed, use
Install-Module -Name ExchangeOnlineManagement
Am saving them as Strings. Otherwise, Set-Transportrule will hang without any response. as its saves with non standard format
[String] $Newlist = Get-Content "C:\BlockEmail\blocked_addresses_unique_dos.csv" [String] $Oldlist = (get-transportrule bounce).from [String] $All = $Newlist + $Oldlist | select -Unique Set-TransportRule bounce -from $All Write-Host "Updating [$all] to Bounce"
if you want to test without csv
[String] $Newlist = "email@example.com,"firstname.lastname@example.org"