Using Exchange Management Shell to Configure Content Filtering, Part 2
In the previous article in this series (Using Exchange Management Shell to Configure Content Filtering, Part 1), I showed you how to use the Set-ContentFilterConfig command to specify bypassed sender domains in Exchange Server 2007. As you may recall though, the biggest problem was that whenever you enter this command, the existing list of bypassed domains is overwritten.
Suppose for example that you wanted to list Microsoft.com and Contoso.com as bypassed sender domains. It would stand to reason that you could accomplish this by entering the following commands:
Set-ContentFilterConfig –BypassedSenderDomains Microsoft.com
Set-ContentFilterConfig –BypassedSenderDomains Contoso.com
However, if you enter these two commands in sequence then the listing for Microsoft.com will be replaced by Contoso.com. There is a way to add both domains (and any other domains that you may want to include) to the list of bypassed sender domains, but it is a little bit tricky.
Say Goodbye to Traditional PC Lifecycle Management
Traditional IT tools, including Microsoft SCCM, Ghost Solution Suite, and KACE, often require considerable custom configurations by T3 technicians (an expensive and often elusive IT resource) to enable management of a hybrid onsite + remote workforce. In many cases, even with the best resources, organizations are finding that these on-premise tools simply cannot support remote endpoints consistently and reliably due to infrastructure limitations.
If you want to append additional data to a property that already contains data, so as to create a multi valued property, you will have to make use of variables. In the previous article, I showed you how you could use the Get-ContentFilterConfig command to display the data that is already in the content filter. What we can do is to assign this command to a variable. That way, all of the data that currently resides in the content filter is assigned to a variable. In this particular case, the actual command that you would use is:
$list = (Get-ContentFilterConfig).BypassedSenderDomains
Notice in the command above that the name of the variable that we are using is $LIST. In the Exchange Management Shell, variables are always specified by using a dollar sign. When we assign the variable, we place the Get-ContentFilterConfig command in parenthesis, but the actual property that we want to use is appended outside of the parenthesis (in this case it’s .BypassedSenderDomains).
If you are interested in seeing the variable’s contents, you can just enter the variable’s name as a command. In this case, if you type $LIST, you will see a formatted list of the sender domains which are currently being bypassed, as shown in Figure A.
Entering the $LIST command displays the contents of the variable $List.
Now that we have copied our bypassed sender domains list to the $list variable, it’s time to add the Contoso.com domain to the bypassed sender domains list. To do so, you must simply append the Add command to the $List variable, and then specify the domain that you want to add. For example, to add the Contoso.com domain to the bypassed sender domains list, you would enter the following command:
If you enter the $List command again, you can see that both the Microsoft.com and the Contoso.com domains are now included on the list of bypassed sender domains, as shown in Figure B.
Entering the $List command reveals that both domains have now been added to the list of bypassed sender domains.
So far I have shown you how to use variables to manage the bypassed sender domains. You can use the exact same technique though if you want to manage a list of individual bypassed senders rather than bypassing entire domains. For example, if you wanted to add my e-mail address to the list of bypassed senders, the commands would be:
$List = (Get-ContentFilterConfig).BypassedSenders
Again, you can use the $List command to verify the filter’s contents. Likewise, you can enter the $List.add command multiple times to add multiple senders to the list.
One last concept that I want to discuss is that of removing items from the list of bypassed senders or bypassed sender domains. In the previous article, I mentioned that you could remove an item by replacing it, but this technique no longer works if you have multiple entries on the list. If you were to enter a single Set-ContentFilterConfig -BypassedSenderDomains command, you would overwrite the entire list rather than a single entry.
If you want to remove an individual item from the list, you must use the same variable technique that I have been discussing throughout this article. The difference is that rather than using the $List.Add command, you will use the $List.Remove command. For example, if you wanted to remove my e-mail address from the bypassed senders list, the command would look like this:
Again, you can enter the $List command to verify the removal.
Once you are satisfied with the contents of the $List variable, you need to commit the variable’s contents to the content filter by running this command:
In this article, I have explained that if you want to manage a multi-property list, then you will have to resort to using variables & went on to show you how. I hope you find this new Exchange Server 2007 content filtering as exciting and powerful as I do!