How to Set Multiple RecipientAddressContainsWords Values in Exchange PowerShell
Question details
The user needs to configure an Exchange transport rule with multiple email addresses for the RecipientAddressContainsWords parameter.

- 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.
Ensure you are connected to Exchange Online PowerShell or your local Exchange Server and possess the necessary Organization Management or Exchange administrator permissions.
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.
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")
Execute the Set-TransportRule cmdlet using the variable you just created. For example: Set-TransportRule -Identity "Rule1" -RecipientAddressContainsWords $MailAddr

Load Email Addresses from a Text File
If you are managing a large list of email addresses, it is more efficient to store them in a text file and read them into your PowerShell script dynamically.
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. Download the Installer: Visit the official WPS Office website and click the free download button to get the installer package.
- 2. Install WPS Office: Run the downloaded file and follow the quick setup wizard to install the software on your system.
- 3. Open and Edit Documents: Launch WPS Office to instantly open, create, and manage your documents, spreadsheets, and presentations with full Microsoft compatibility.

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.




