Solved

Deleting multiple AD User accounts from CSV file

Posted on 2013-11-29
5
2,785 Views
Last Modified: 2014-02-14
Hello,

I need to delete AD users along with their Exchange accounts via the attached CSV file, I have the SANaccountname field available, I have Exchange 2007 with AD 2003

I would guess the best way to do this is via Powershell on the Exchange server, can you assist?
Userstobedeleted.csv
0
Comment
Question by:ProjNet
  • 2
5 Comments
 
LVL 35

Expert Comment

by:Mahesh
ID: 39685356
You can use code mentioned in below article as powershell script (ps1) in exchange 2007 shell

http://randomtechminutia.wordpress.com/2012/05/03/powershell-script-to-delete-exchange-mailboxes-in-mass/

It will disable mailbox and delete user as well from AD for the list of users

Mahesh
0
 
LVL 37

Accepted Solution

by:
Jamie McKillop earned 500 total points
ID: 39685389
Hello,

The specific code you want to use is:

$Users = Import-Csv C:\userstobedeleted.csv
foreach ($user in $users) {
	remove-mailbox $user."SAM Account Name" -Permanent $true
}

Open in new window


Change the path to your CSV as appropriate.

-JJ
0
 

Author Comment

by:ProjNet
ID: 39689575
thanks guys,

Jjmck, this worked beautiful, only thing is the notification asking if I wanted to apply these changes kept appearing per account, it gives me an option to say yes to all (A), but it kept constantly coming back for each account, any ideas?
0
 
LVL 37

Expert Comment

by:Jamie McKillop
ID: 39689740
Add -confirm: $false to the end of the remove-mailbox command.

-JJ
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
This article explains in simple steps how to renew expiring Exchange Server Internal Transport Certificate.
In this video we show how to create an Accepted Domain in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Ac…
how to add IIS SMTP to handle application/Scanner relays into office 365.

920 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

14 Experts available now in Live!

Get 1:1 Help Now