Frequently I need to update a list in the EMS and invariably I forget how to go about it precisely.
A classic example is needing to update the BypassedSenders in the ContentFilterConfig settings. So for example say that
Get-ContentFilterConfig reveals that we have 3 email addresses in the BypassedSenders. [email protected], [email protected], [email protected] We can either write these down, copy from the screen to notepad or some other clumsy form of recording this info, and then paste it back into our list for the Set-ContentFilterConfig -BypassedSenders [email protected], [email protected], [email protected], [email protected]
But you have to admit. That sucks a a way to do this fairly common task. What if you had 30 in there and want ed to add another 4. Ugly!
The neatest way is probably to use GSEXDEV’s excellent Whitelist GUI script. This is a great yet simple but of code (script) that for those of you that don’t like playing with a shell, is brilliant. But I am an old fashioned kind of guy and I like doing this kind of thing myself (long hand) as it keeps my hand in using the powershell (EMS) and it’s fun, so…
- Open the EMS (Exchange Management Shell)
- and assign the entire ContentFilterConfig to a variable
- check that it has done as expected and look at what is in your BypassedSenders already
- Typing $BPS.BypassedSenders should show you all email addresses their already.
- you can now use the .add method to add additional addresses
- Type $BPS.BypassedSenders again will confirm the added address.
- Now simply use Set-ContentFilterConfig to write your configuration and you are done.
[PS] C:Ramtech> $BPS = Get-ContentFilterConfig [PS] C:Ramtech> $BPS.BypassedSenders.Add("[email protected]") [PS] C:Ramtech> $BPS.BypassedSenderDomains.Add("NewDomain.com") [PS] C:Ramtech> Set-ContentFilterConfig -BypassedSenders $BPS.BypassedSenders [PS] C:Ramtech> Set-ContentFilterConfig -BypassedSenderDomains $BPS.BypassedSenderDomains
This will work for any list of course and saves an awful lot of typing. Particularly if you are using <Tab> completion. So for example if you type $get-con and hit tab a couple of times you will get the Get-ContentFilterConfig command up with no typos:) It works with the variables and methods too if you forget the exact syntax.
You can also use the
, as Microsoft suggests, to just store the list you are dealing with but this is a lot more typing as there is no <Tab> word completion due to the necessity to enclose the cmdlet in brackets. So for geese like me who type at the speed of a thousand startled snails, this is tedious. The other benefit of dealing with the whole config is, if you want to change other settings at the same time, say BypassedSenderDomains, it’s all there for you already with the benefit of <Tab> completion. So you could do a
$BPS.BypassedSenders.add("<Bypassed Email Address list>")
$BPS.BypassedSenderDomains.add("<Bypassed Domian list>")
and anything else you wanted updated then just use
and update the whole lot if you wanted.
It really is easy once you get the hang of it but if you like neat, use Glen’s GUI.