Solved

Delete multiple AD users with or without mailbox

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
This article demonstrates probably the easiest way to configure domain-wide tier isolation within Active Directory. If you do not know tier isolation read https://technet.microsoft.com/en-us/windows-server-docs/security/securing-privileged-access/s…
The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

756 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