Solved

Delete multiple AD users with or without mailbox

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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Lotus Notes – formerly IBM Notes – is an email client application, while IBM Domino (earlier Lotus Domino) is an email server. The client possesses a set of features that are even more advanced as compared to that of Outlook. Likewise, IBM Domino is…
Read this checklist to learn more about the 15 things you should never include in an email signature.
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…
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 …

910 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

22 Experts available now in Live!

Get 1:1 Help Now