logo
search
Others

How to Set Multiple RecipientAddressContainsWords Values in Exchange PowerShell

Camila MilosovichCamila Milosovich Oct 8, 2026 869 views

Question details

The user needs to configure an Exchange transport rule with multiple email addresses for the RecipientAddressContainsWords parameter.

How to Set Multiple RecipientAddressContainsWords Values in Exchange PowerShell
Product
Exchange PowerShell
Device & OS
not provided
Scenario
Creating or updating a transport rule in Exchange using PowerShell and providing a list of multiple specific recipient addresses.
Observed behavior
The user requires the correct PowerShell syntax to successfully pass multiple email addresses without triggering parsing errors, especially when reading from a text file.
Before you start

Ensure you are connected to Exchange Online PowerShell or your local Exchange Server and possess the necessary Organization Management or Exchange administrator permissions.

Solution 1Recommended

Use a PowerShell Array for Multiple Email Addresses

This method is best when you have a small, fixed list of email addresses to include in the transport rule. You can define them directly within your script as an array.

By utilizing a standard PowerShell array, you can bundle multiple string values into a single variable. The Set-TransportRule cmdlet will natively accept this array and apply it to the RecipientAddressContainsWords parameter.

1
Define the email address array

Open your PowerShell console and declare the variable containing your target email addresses formatted as an array. For example: $MailAddr = @("user1@domain.com", "user2@domain.com")

2
Apply the array to the transport rule

Execute the Set-TransportRule cmdlet using the variable you just created. For example: Set-TransportRule -Identity "Rule1" -RecipientAddressContainsWords $MailAddr

Use a PowerShell Array for Multiple Email Addresses
Free Microsoft Office alternative

Looking for a Lightweight Alternative for Your Office Documentation?

While configuring Exchange transport rules requires PowerShell, managing your daily IT documentation, reports, and spreadsheets doesn't have to rely on heavy, expensive software. WPS Office provides a free, lightweight, and highly compatible suite for all your productivity needs.

  1. 1. Download the Installer: Visit the official WPS Office website and click the free download button to get the installer package.
  2. 2. Install WPS Office: Run the downloaded file and follow the quick setup wizard to install the software on your system.
  3. 3. Open and Edit Documents: Launch WPS Office to instantly open, create, and manage your documents, spreadsheets, and presentations with full Microsoft compatibility.
Fully compatible with Microsoft Word, Excel, and PowerPoint formats (.docx, .xlsx, .pptx).Lightweight installation package with a fast, responsive tabbed interface.Perfect for IT administrators to easily document PowerShell scripts, logs, and network setups.Free alternative to Microsoft Office without mandatory cloud subscriptions.
QA img-9

Frequently Asked Questions

Can I use a comma-separated list inside the text file when using Get-Content?

No. The Get-Content cmdlet reads the file line by line to create a string array. If you put all email addresses on one line separated by commas, PowerShell reads it as a single continuous string. You must put one email address per line in your text file.

How do I add new addresses to an existing RecipientAddressContainsWords list?

To append addresses, you first need to capture the existing rule properties into a variable, extract the current addresses, add your new addresses to that array, and then push the updated array back to the rule using Set-TransportRule.

Why am I getting an error that the Set-TransportRule command is not recognized?

This error occurs if the Exchange PowerShell module is not loaded or if your account lacks the necessary administrative permissions. Make sure you are properly connected to Exchange Online or your local Exchange server and hold the Organization Management role.