Exchange Online set-transportrule syntax question

Copper Contributor

Hi Team,

 

I hope you are all doing well,

 

I have created Transport Rule in Exchange with the following parameters:

 

HeaderContainsMessageHeader : From
HeaderContainsWords : {Test1, Test2, Test3, Test4...}

 

I would like to add a new word to the HeaderContainsWords property with:

 

Set-TransportRule "Rule Name" -HeaderContainsMessageHeader From -HeaderContainsWords @("Test10")

 

but this actually deletes my old list {Test1, Test2, Test3, Test4...} and after executing the cmdlet I have only:

HeaderContainsWords : {Test10} ; and I would like to append the list with Test10 - keep the old values + the new One Test10 as the example bellow:

HeaderContainsWords : {Test1, Test2, Test3, Test4,TEST10...}

 

Any suggestion will be highly appreciated. 

 

1 Reply

In PowerShell, @() designates a list, thus the example you are using replaces the entire content of the list. if you want to add an element to the list, you have to do it by copying the current value, adding to it, then passing it to the cmdlet.

 

Generally speaking, in some cases you can use the hash-table notation instead, but it's not supported for this particular parameter.