Solved

Delete multiple AD users with or without mailbox

Posted on 2015-02-23
2
77 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 500 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

Suggested Solutions

Title # Comments Views Activity
NLB +DAG 8 44
search option in outlook 2016 not working? 11 85
Exchange 2016 - Archiving and Retention Policies 1 43
Chrome does not work from a remote desktop session 6 93
Always backup Domain, SYSVOL etc.using processes according to Microsoft Best Practices. This is meant as a disaster recovery process for small environments that did not implement backup processes and did not run a secondary domain controller that ne…
Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …
how to add IIS SMTP to handle application/Scanner relays into office 365.

738 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