Solved

Delete multiple AD users with or without mailbox

Posted on 2015-02-23
2
70 Views
Last Modified: 2015-02-23
Hello,

We have a monthly report that requires users to get deleted from our domain. I have modified the report to output the SamAccountName to a CSV.  I'm trying to find a simple way to delete multiple AD accounts that may or may not have mailboxes.

I found this great article but it only seems to work if the user has a mailbox. I'm wondering if anyone can expand on it or suggest something simpler.

http://www.experts-exchange.com/Software/Server_Software/Email_Servers/Exchange/Q_28306536.html
0
Comment
Question by:apimentel26
2 Comments
 
LVL 53

Accepted Solution

by:
Will Szymkowski earned 500 total points
Comment Utility
It really should not matter if the user has a mailbox or not because ultimately if you delete an AD Account with a mailbox the mailbox goes into a disconnected state and is purged after X days (default 60).

Use the following command below....
Import-module activedirectory
$Users = import-csv "c:\filename.csv"
ForEach ($User in $Users) {
$User.samaccountname
Remove-ADUser -Identity $User.samaccountname -confirm:$false
}

Open in new window


That should do it.

Will.
0
 

Author Comment

by:apimentel26
Comment Utility
Thank you for pointing that out. This helps big time.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

We are happy to announce a brand new addition to our line of acclaimed email signature management products – CodeTwo Email Signatures for Office 365.
A safe way to clean winsxs folder from your windows server 2008 R2 editions
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…
how to add IIS SMTP to handle application/Scanner relays into office 365.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now