Solved

Deleting multiple AD User accounts from CSV file

Posted on 2013-11-29
5
3,120 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
[X]
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
  • 2
5 Comments
 
LVL 37

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

Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

Had a business requirement to store the mobile number in an environmental variable. This is just a quick article on how this was done.
This process allows computer passwords to be managed and secured without using LAPS. This is an improvement on an existing process, enhanced to store password encrypted, instead of clear-text files within SQL
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…
This video demonstrates how to sync Microsoft Exchange Public Folders with smartphones using CodeTwo Exchange Sync and Exchange ActiveSync. To learn more about CodeTwo Exchange Sync and download the free trial, go to: http://www.codetwo.com/excha…
Suggested Courses

627 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