Delete Computer accounts

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



I ahve a number of computer accounts I need to delete. The computer objects
are in multiple different OUs. How do I create a script to delete the
accounts? I am using the following for deleting from a specific OU:

Do Until objTextFile.AtEndOfStream

strComputer = objTextFIle.Readline
'wscript.echo strComputer
set objComputer = GetObject("LDAP://CN="; & strComputer & _
",OU=myou,DC=mycomp,DC=edu")
If err.number <> 0 then
wscript.echo "Error deleting computer object."
err.clear
Else
wscript.echo "Deleting " & strComputer
objComputer.DeleteObject (0)
End If

Loop

I just need to know how to write it so that it searches the entire directory
instead of the specified OU.

Any inisght is greatly apprecaited.

Thanks,

JEff


.



Relevant Pages

  • Re: Couple of Server 2003 OU Questions
    ... Is there a way to make Active Directory place any computer objects created with a certain user account default to a particular OU? ... can we make it so that when a local Admin staff member adds a computer to the domain that it shows up in their own OU? ... The easiest way to do that is to use a) a good naming convention that you enforce with an iron fist and allows you to understand what OU a computer account belongs in at a glance and b) a process change to teach an OU administrator to create computer accounts in their OU prior to joining a domain. ...
    (microsoft.public.windows.server.active_directory)
  • Re: Convert to secure ADI from Bind
    ... moved the zones to ADI and Dynamic Update i notice no computer accounts ... For servers or other critical machines delete them and run ... Save the list of stations you are deleting and feed this to the ... the same records and updating with ipconfig afterwards. ...
    (microsoft.public.windows.server.dns)
  • Re: Missing Computer Accounts
    ... My thought also is that someone or something is actually deleting the ... thoughts on why the event in not showing up in Event Viewer? ... I have an issue where computer accounts just randomly go missing in Active ... event viewer - security - account management I can see the entry detailing ...
    (microsoft.public.windows.server.active_directory)
  • Re: Missing Computer Accounts
    ... My thought also is that someone or something is actually deleting the objects, however, I can't explain why I don't see the record of the deletion in Event Viewer, Security under Account Management. ... It's been my experience that computer accounts don't randomly get suicidal and leave the domain. ...
    (microsoft.public.windows.server.active_directory)
  • Re: Delegation of permission to join domain
    ... delegation wizard, your template would look something like... ... >the computer accounts are to a group called desktop support. ... > Change Password ... > Create Computer Objects ...
    (microsoft.public.windows.server.general)