34.5 C
Monday, June 17, 2024

Bulk Update Exchange Online Transport Rules using CSV and PowerShell

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 =  "x@y.com,"y@g.com"

Satheshwaran Manoharan
Satheshwaran Manoharanhttps://www.azure365pro.com
Award-winning Technology Leader with a wealth of experience running large teams and diversified industry exposure in cloud computing. From shipping lines to rolling stocks.In-depth expertise in driving cloud adoption strategies and modernizing systems to cloud native. Specialized in Microsoft Cloud, DevOps, and Microsoft 365 Stack and conducted numerous successful projects worldwide. Also, Acting as a Technical Advisor for various start-ups.

Related Articles


Please enter your comment!
Please enter your name here