15. December 2009 09:00
Don’t you hate when you have large distribution groups in your environment with enabled and disabled accounts as members and when you send email messages to the account NDRs are sent throughout the environment. As may or may not know, there are options in Exchange on how to handle NDRs for distribution groups. My issue is with the options provided by Exchange, for example enabling certain features against a DG could remove valid NDRs or create a lot of false positives. To combat this problem in environments we put together a script that will only look in DG, not security groups, and remove disabled user accounts. This script will remove all groups from disabled users within a particular OU. You have to specify the OU that you want to search for the disabled mailboxes. This will also write out the removed groups of each user to a log.
The script can be found on our Tools page or directly at this link: http://cbfive.com/blog/page/Remove-Disabled-Users-from-Distribution-Groups.aspx.
BTW, if you are looking for the same functionality but with Security Groups, it wouldn't take much to modify this script to that effect.