I think I’m probably still not understanding.
$collection = Get-Transportrule test | select -expand RecipientAddressContainsWords
$collection now contains the current rules, yes?
$collection += 'test.com','test2.com'
Now you have added two items to the rules.
set-transportrule test -RecipientAddressContainsWords $collection
Please understand that I don’t know what Set-TransportRule is doing. I’m also entirely unsure what you are trying to achieve. I know PowerShell, but I do not know Exchange very well. If you’re not understanding what the Exchange command does, or what it needs, please post a new question and in the subject be sure to specify that you are asking about Exchange. That makes it easier for an appropriate person to look at your question.
But I think the problem is your understanding of the command. The -RecipientAddressContainsWords can accept a collection of multiple values. What your command is doing is giving it one value at a time. So you are setting the rule to contain “test.com,” then you are setting it to only contain “test2.com,” and so on. Running the command multiple times is not cumulative. Each time you run it, it replaces the last time. To give it multiple values, you run the command ONCE (not in a ForEach), and give it ALL the values, as a collection of strings.
I hope that helps.