• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 591
  • Last Modified:

Command or Script to delete a list of Domain User accounts

I have a list of domain user accounts. I need a script or a command to delete those domain user accounts from AD. Thanks
  • 3
  • 2
3 Solutions
Venugopal NCommented:
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
 -i import
-s DC name
-f filename.
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:

I would be tempted to create a separate OU and disable the user accounts and move them there instead of deleting them
jmohan0302Author Commented:
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
Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

Venugopal NCommented:
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.


For syntax

jmohan0302Author Commented:
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
Venugopal NCommented:
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"
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now