Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Command or Script to delete a list of Domain User accounts

Posted on 2012-04-09
6
Medium Priority
?
586 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
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Always backup Domain, SYSVOL etc.using processes according to Microsoft Best Practices. This is meant as a disaster recovery process for small environments that did not implement backup processes and did not run a secondary domain controller that ne…
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..
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

636 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