Block a bunch of senders using Shell Command
Hello,When I type the below command It blocked all the senders I've got in my text docmuent (Using Exchange 2007) Set-SenderFilterConfig -BlockedSenders (Get-Content C:\BlockedList.txt)however, it removes all the existing senders I have manually entered from Exchange console management. Can anyone help me out for not deleting sender manually enter in the Exchange console?How could I recover my senders prior block before I run theabove shellcommand?
May 14th, 2009 11:27am

I didn't test this sicne I don't have test environment rightnow. But it should work as per below article...Modifying Multivalued Propertieshttp://technet.microsoft.com/en-us/library/bb684908.aspxSo it should be something like below...$Example = Get-RecipientFilterConfig$Example.BlockedRecipients += (Get-Content C:\BlockedList.txt)Set-RecipientFilterConfig -BlockedRecipients $Example.BlockedRecipientsAmit Tank | MVP - Exchange Server | MCITP:EMA MCSA:M | http://ExchangeShare.WordPress.com
Free Windows Admin Tool Kit Click here and download it now
May 14th, 2009 11:48am

I did test it. And If I manually add a sender from the Exchange console management E.g test1@domain.comand I check it up still in theExchange console management I can see that user blocked.But then if I created a notepad document with liste of users E.g. test2@domain.comand test3@domain.comandrun the shell command Set-RecipientFilterConfig -BlockedRecipients $Example.BlockedRecipientsWhen I reopen the Exchange console Management and check the blocked sender I only have test2@domain.comand test3@domain.comBLOCKEDAnd test1@domain.com is removed.Can anybody help on not removing the senders manually added from the console??How can I get an history of senders blocked on the edge in the past?? (last month or last 2 months)??
May 14th, 2009 12:21pm

Okay, I managed to try this in test environment. Follow below steps... ~ Create a CSV file with list of recipients in below format, make sure that you have "BlockedRecipient" column header at the top of all recipient as per below... BlockedRecipients test2@domain.com test3@domain.com ~ Now run below cmdlest, first one get the existing recipient in $Example variable, second cmdlet will ADD recipients in $Example.BlockedRecipient one by one from csv file, third cmdet will set all recipient in Recipient Filter Configuration (set of old recipient plus new recipient stored into $Example.BlockedRecipient). $Example = Get-RecipientFilterConfig Import-csvC:\BlockedList.csv| foreach { $Example.BlockedRecipients += $_.BlockedRecipients} Set-RecipientFilterConfig -BlockedRecipients $Example.BlockedRecipients ~ It is not possible to get history of blocked recipient and you need to maintain it with your own database somewhere in excel or any other format. :) Amit Tank | MVP Exchange Server | MCITP: EMA | MCSA: M | http://ExchangeShare.WordPress.com
Free Windows Admin Tool Kit Click here and download it now
May 24th, 2009 5:22pm

Thank you very much for the explanation. Though (as you have a test environement). I would need to be sure that if you run shell command:Import-csvC:\BlockedList.csv| foreach { $Example.BlockedRecipients += $_.BlockedRecipients}FROM the csv file: BlockedRecipients test2@domain.com test3@domain.com You should have test2@domain.com and test3@domain.com blocked.NOW, if you manually add a user to be blocked (from the exchange console management). Eg: add test4@domain.com If you run agin your prior shell command:Import-csvC:\BlockedList.csv| foreach { $Example.BlockedRecipients += $_.BlockedRecipients}Would that keep your entry test4@domain.comsaved??
May 25th, 2009 3:40pm

Yes, I had test2 and test3 listed in BlockedRecipients, then I added test4@domain.com into csv file and ran these cmdlets again and now I have test1-4 listed in Get-RecipientFilterConfig result. So conclusion is while adding multiple entries from csv file you need to run below three cmdlets everytime... $Example = Get-RecipientFilterConfig Import-csvC:\BlockedList.csv| foreach { $Example.BlockedRecipients += $_.BlockedRecipients} Set-RecipientFilterConfig -BlockedRecipients $Example.BlockedRecipients Amit Tank | MVP Exchange Server | MCITP: EMA | MCSA: M | http://ExchangeShare.WordPress.com
Free Windows Admin Tool Kit Click here and download it now
May 25th, 2009 4:15pm

Thanks and Sorry.. maybe I am not clear enough. but I am talking about blocking a user from the Exchange console management and not adding a new user in the CSV file and run the shell command again.The problem I had before was that users added to the csv file were well blocked on the edge but users added from the Exchange CONSOLE Management were added but erased when I was re-runing the shell command. It looks like as long as I update the csv file and run the shell command users are correctly block on the Edge. Example:Day 1:my CSV file: BlockedRecipients test2@domain.comI run the shell command Import-csvC:\BlockedList.csv| foreach { $Example.BlockedRecipients += $_.BlockedRecipients}result --> test2@domain.com IS BLOCKEDDay 2:I manually block from Exchange console management the user test3@domain.comresult --> test2@domain.com and test3@domain.com ARE BLOCKEDDay 3:I just run again the shell command without modifing anything.result --> test2@domain.com IS BLOCKED AND test3@domain.comhas been erased or removeso here is the problem.Does it work for you then??
May 25th, 2009 4:55pm

Import-csvC:\BlockedList.csv| foreach { $Example.BlockedRecipients += $_.BlockedRecipients} Are you running just this command of all there lines I mentioned? $Example = Get-RecipientFilterConfig Import-csvC:\BlockedList.csv| foreach { $Example.BlockedRecipients += $_.BlockedRecipients} Set-RecipientFilterConfig -BlockedRecipients $Example.BlockedRecipients Amit Tank | MVP Exchange Server | MCITP: EMA | MCSA: M | http://ExchangeShare.WordPress.com
Free Windows Admin Tool Kit Click here and download it now
May 25th, 2009 4:59pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics