[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Delete multiple AD users with or without mailbox

Posted on 2015-02-23
2
Medium Priority
?
81 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 53

Accepted Solution

by:
Will Szymkowski earned 2000 total points
ID: 40626100
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
ID: 40626168
Thank you for pointing that out. This helps big time.
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn't it be nice if objects in Active Directory automatically moved into the correct Organizational Units? This is what AutoAD aims to do and as a plus, it automatically creates Sites, Subnets, and Organizational Units.
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
This tutorial will show how to configure a single USB drive with a separate folder for each day of the week. This will allow each of the backups to be kept separate preventing the previous day’s backup from being overwritten. The USB drive must be s…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Suggested Courses

649 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