?
Solved

Command or Script to delete a list of Domain User accounts

Posted on 2012-04-09
6
Medium Priority
?
588 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
  • 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
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 
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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

Active Directory can easily get cluttered with unused service, user and computer accounts. In this article, I will show you the way I like to implement ADCleanup..
Transferring FSMO roles is done when an admin wants to split roles between certain Domain Controllers or the Domain Controller holding the Roles has been forcefully demoted using dcpromo / forceremoval
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…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

809 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