Add email addresses to an exchange transport rule via PowerShell

Nick Paramonov 46 Reputation points
2022-02-10T09:19:46.197+00:00

Hi

I need to script adding new email addresses to transport rules via powershell.

I can get the list of email addresses using Get-TransportRule | Select-Object -ExpandProperty From

Which gives me the full list of addresses in this rule as a plain text. How do I script appending more addresses there?
Thanks

Microsoft Exchange Online Management
Microsoft Exchange Online Management
Microsoft Exchange Online: A Microsoft email and calendaring hosted service.Management: The act or process of organizing, handling, directing or controlling something.
4,153 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Vasil Michev 94,366 Reputation points MVP
    2022-02-10T11:06:48.213+00:00

    It's an array actually, and you can add to it:

    $from = Get-TransportRule "blabla" | select -ExpandProperty From
    $from += "user1"
    $from += "user2","user3","user4"
    $from
    
    Set-TransportRule "blabla" -From $from
    
    0 comments No comments