AD - Disable User and Remove Distribution List Same Time?

I am in the process on learning how to disable a bunch of users at once in AD.  As I am researching on how to do this, I realized that I will still have to go in and alter each account to remove the distributions emails lists that everyone is assigned to.  Is there a way to disable and remove distribution list at the same time?  

DNS: Windows Server 2008RS
Exchange: 2010
UmpquaITAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Will SzymkowskiSenior Solution ArchitectCommented:
Yes you can do this use the following command...

The Example below illustrates how to accomplish this if you have a bunch of users in a text file.
Import-module activedirectory
$FindGroups = get-content c:\filename.txt | Get-ADPrincipalGroupMembership
ForEach ($user in $FindGroups) {
Set-ADUser -Identity $user -Enabled $false | Remove-ADPrincipalGroupMembership -MemberOf $FindGroups
}

Open in new window


Will.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
compdigit44Commented:
If an account is disabled it wouldn't be able to receive email since Exchange would not be able to authenticate the account since it is disabled.... At least this is what I am thinking
UmpquaITAuthor Commented:
Thank you.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Exchange

From novice to tech pro — start learning today.