?
Solved

Command or Script to delete a list of Domain User accounts

Posted on 2012-04-09
6
Medium Priority
?
584 Views
Last Modified: 2012-05-17
I have a list of domain user accounts. I need a script or a command to delete those domain user accounts from AD. Thanks
0
Comment
Question by:jmohan0302
[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
  • 3
  • 2
6 Comments
 
LVL 11

Accepted Solution

by:
Venugopal N earned 999 total points
ID: 37826443
You can use the lDIF untility to delete the bulk users.Before that you need to put the list of users in the below format in an notepad and save with extension .ldf

dn: CN=user1,OU=Marketing,DC=reskit,DC=com
dn: CN=user2,OU=Marketing,DC=reskit,DC=com
dn: CN=user3,OU=Marketing,DC=reskit,DC=com
.
.
.
.
changetype: delete.

Once you have done the creation of the file then run the comamnd

ldifde –i -f filename.ldf -s DC
Where:
 -i import
-s DC name
-f filename.
0
 
LVL 4

Assisted Solution

by:julian_brunt
julian_brunt earned 501 total points
ID: 37826486
using VBS this is the snippet to delete the user account
' Delete a User Account from Active Directory


Set objOU = GetObject("LDAP://ou=hr,dc=fabrikam,dc=com")

objOU.Delete "user", "cn=MyerKen"

Such scripts are available here:
http://gallery.technet.microsoft.com/scriptcenter

** HOWEVER **
I would be tempted to create a separate OU and disable the user accounts and move them there instead of deleting them
0
 

Author Comment

by:jmohan0302
ID: 37831136
Hi Venurajav:

Thanks a lot. Could you please give me the link from where I can download the LDIFDE.exe and also gimme the exact syntax for LDIFDE for deleting the file. Thanks
0
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.

 
LVL 11

Assisted Solution

by:Venugopal N
Venugopal N earned 999 total points
ID: 37831169
By default it will be avaiable on windows server os in %systemroot%\system32 .If not you can get the tool from the support tool folder on the  OS CD.

http://www.petri.co.il/list_all_users_and_groups_in_domain.htm

For syntax

http://technet.microsoft.com/en-us/library/bb727091.aspx
0
 

Author Comment

by:jmohan0302
ID: 37831927
Hi Venurajav,

I tried to execute but getting the following error:

Connecting to "FRMA705"

Logging in as current user using SSPI

Importing directory from file "del1.ldf"

Loading entries
1: CN=BALOGH Diana,OU=Users,OU=FR,DC=fr,DC=euro,DC=biomerieux,DC=net
Entry DN: CN=BALOGH Diana,OU=Users,OU=FR,DC=fr,DC=euro,DC=biomerieux,DC=net
changetype: delete
Add error on line 1: Not allowed on Non-leaf

The server side error is "The directory service can perform the requested operation only on a leaf object."

0 entries modified successfully.

An error has occurred in the program


Kindly help me
0
 
LVL 11

Expert Comment

by:Venugopal N
ID: 37836684
I think the DN specified is not correct.

Run the below command and Which will give you the right DN for the user.Use this DN and try to delete the user by using ldifde,

Dsquery OU –name "BALOGH Diana"
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article shows the method of using the Resultant Set of Policy Tool to locate Group Policy that applies a particular setting.
After seeing many questions for JRNL_WRAP_ERROR for replication failure, I thought it would be useful to write this article.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Suggested Courses

777 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