Multivalued attributes are simply attributes that can have more than one value. Examples include members attribute of groups, or proxyAddresses attribute of recipients.
In GUI interfaces, it is simple to add/modify multivalued attributes. VBScript has control codes that allow you to control the interaction with multi-valued attributes - 1 = clear all entries, 2 = update all entries, 3 = append, and 4 = delete.
Exchange shell uses Add commands to add new entries to some multivalued attributes - e.g. Add-IPBlockListEntry to add another IP address or range to the IP Block List.
However, if you want to add more values to stuff like BypassedSenderDomains in ContentFilterConfig, there's no equivalent of an Add command. If you try to add a value to the attribute using the following syntax, the existing values will be replaced by the newer ones:
However, it'd be much easier to have a switch that lets you append to such multi-valued attributes, in keeping with the shell's promise of allowing most operations using one-liners.. something like Set-ContentFilterConfig -BypassedSenderDomains +domainthree.com,domainfour.com to add values to the attribute, and some other combination to remove a particular value.
Update:
To remove a value from a multivalued attribute, for example from the BypassedSenderDomains property of the ContentFilterConfig used in the preceding example:
In GUI interfaces, it is simple to add/modify multivalued attributes. VBScript has control codes that allow you to control the interaction with multi-valued attributes - 1 = clear all entries, 2 = update all entries, 3 = append, and 4 = delete.
Exchange shell uses Add commands to add new entries to some multivalued attributes - e.g. Add-IPBlockListEntry to add another IP address or range to the IP Block List.
However, if you want to add more values to stuff like BypassedSenderDomains in ContentFilterConfig, there's no equivalent of an Add command. If you try to add a value to the attribute using the following syntax, the existing values will be replaced by the newer ones:
Set-ContentFilterConfig -BypassedSenderDomains "somedomain.com"
You could copy the existing values (e.g. microsoft.com,zenprise.com), and paste these along with the new value:Set-ContentFilterConfig -BypassedSenderDomains "microsoft.com","zenprise.com","somedomain.com"
However, this copying and pasting can be tricky for attributes that have a lot of values. Another alternative (..thanks to Vivek for the suggestion):$foo=Get-ContentFilterConfig
$foo.BypassedSenderDomains +="somedomain.com"
$foo | Set-ContentFilterConfig
However, it'd be much easier to have a switch that lets you append to such multi-valued attributes, in keeping with the shell's promise of allowing most operations using one-liners.. something like Set-ContentFilterConfig -BypassedSenderDomains +domainthree.com,domainfour.com to add values to the attribute, and some other combination to remove a particular value.
Update:
To remove a value from a multivalued attribute, for example from the BypassedSenderDomains property of the ContentFilterConfig used in the preceding example:
$foo=Get-ContentFilterConfig
$foo.BypassedSenderDomains -="somedomain.com"
$foo | Set-ContentFilterConfig
Labels: Anti-Spam, Exchange Server 2007, Exchange Shell, IMF

Exchangepedia Blog is read by visitors from all 50 US States and 150 countries world-wide


10 Comments:
The correct syntax for adding multiple values is
Set-ContentFilterConfig -BypassedSenderDomains "microsoft.com","zenprise.com","somedomain.com"
The problem I have been having with powershell and anti-spam is this....
say I did this command...
Set-ContentFilterConfig -BypassedSenderDomains "microsoft.com","zenprise.com","somedomain.com"
Ok now tommorrow I run that SAME command with different domains. It is going to wipe out everything that I put in there in the first place.
Correct me If I am wrong, but basically, you have to keep a txt file with every domain, and each time you run this command, you must include all domains. It seems to me the powershell only remembers the command 1 time, and wipes out whatever domains you had in there the last time.
This is a huge problem, because it also happens when I try to add emails to the whitelist. if you add 5 users, then 5 later, you still only have the last 5 when you output to the clipboard.
Very useful post, thanx!
I tried this on the
set-attachmentfilterlistconfig
command with "ExceptionConnectors" multivalued argument
but I have the following error:
[PS] C:\Documents and Settings\Administrator>$foo.ExceptionConnectors -="f0484a1
9-771c-46a0-adb9-c5f3a92cd160"
Exception calling "op_Subtraction" with "2" argument(s): "Failed to convert f04
84a19-771c-46a0-adb9-c5f3a92cd160 from System.String to Microsoft.Exchange.Data
.Directory.ADObjectId."
At line:1 char:28
+ $foo.ExceptionConnectors -=" <<<< f0484a19-771c-46a0-adb9-c5f3a92cd160"
basically i just want to remove my connector from this Exclusion list, but i cannot find out how to do it.
This Post is Greattttttt!!!, i have been looking for something like this, i used with receive connectors to set the remoteiprange. thank you very much
I had a similar issue with the AcceptMessagesOnlyFrom attribute of the Set-DistributionGroup. Found the following to work very well:
Set-DistributionGroup -id ‘Test Dist Group’-AcceptMessagesOnlyFrom
((Get-DistributionGroup ‘Test Dist Group’).AcceptMessagesOnlyFrom + ‘Chris Allen’)
Put all that on one line and it should work for you. I tested it and it works great.
wow thanks guys this work for me .......... i was working on this all day....
you guys help big
Somewhere , someone forgot that the purpose of Powershells was to make things EASIER? A little box > add domain > show a list ? Easy. Faffing around with all these little scripts a huge waste of time.
the below commands were very helpful.....
$foo=Get-ContentFilterConfig
$foo.BypassedSenderDomains +="somedomain.com"
$foo | Set-ContentFilterConfig
AWESOME!!!!!!!!
What do you mean AWESOME? IT SUCKS. I've wasted all of this time looking for ways to "fix" what could have been an easy gui tab called "Whitelist domains" that would have all of my entries listed on one page with a simple "add","delete" button at the bottom. How novel; Soooo easy; User friendly even. But No - MS gives us this horrible backwards DOS prompt crap. Now I've got to create my own cheat sheet .txt file to keep track of the stupid dos commands. plus keep an additional .txt file of all of my whitelisted domains because EXCH-07 only remembers the last thing added. You ended your post with "AWESOME!!!!!!!" I'm ending mine with IGNORANT!!!!! (but I'm referring to MS, not you.)
Post a Comment
Links to this post:
Create a Link
<< Home