Solved

Deleting multiple AD User accounts from CSV file

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

Join & Write a Comment

Synchronize a new Active Directory domain with an existing Office 365 tenant
This article explains in simple steps how to renew expiring Exchange Server Internal Transport Certificate.
In this video we show how to create a Distribution Group 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 Recipients >>…
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 to another domain controller. Log onto the new domain controller with a user account t…

743 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

12 Experts available now in Live!

Get 1:1 Help Now