Solved

Deleting multiple AD User accounts from CSV file

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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

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…
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
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 tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

710 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