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
Solved

Deleting multiple AD User accounts from CSV file

Posted on 2013-11-29
5
2,878 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 36

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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

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 process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
This video discusses moving either the default database or any database to a new volume.

840 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