[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Delete a list of computers from Active Directory

Posted on 2009-03-31
3
Medium Priority
?
1,550 Views
Last Modified: 2012-05-06
I have run the dsquery command to show me a list of all the 8 week inactive computers, but there are certain computers inactive that are in an OU I do not want to delete so I can't run the dsquery command to remove all inactive computers.

Is there a way to just delete a list of specific computer names in Active Directory, whether I create a text file with their names, or am able to exclude an OU when removing the machines?
0
Comment
Question by:garryshape
[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 Comments
 
LVL 3

Assisted Solution

by:NPProjects
NPProjects earned 400 total points
ID: 24028649
I'd just go into active directory users and computers and select each pc while pressing ctrl.

By the time you have written a script you could be done.
0
 
LVL 23

Accepted Solution

by:
Mohamed Osama earned 1600 total points
ID: 24028808
If you would prefer scripting this one , please give this VBS script a go, please take the time to test it first


Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("c:\computers.txt", ForReading)
 
Const ForReading = 1
 
Dim arrFileLines()
i = 0
Do Until objFile.AtEndOfStream
Redim Preserve arrFileLines(i)
arrFileLines(i) = objFile.ReadLine
i = i + 1
Loop
objFile.Close
 
'Then you can iterate it like this
 
For Each strLine in arrFileLines
set objComputer = GetObject("LDAP://CN=" & strLine & _
    ",CN=Computers,DC=fabrikam,DC=com")
objComputer.DeleteObject (0)
Next

Open in new window

0
 

Author Closing Comment

by:garryshape
ID: 31564798
The script helped with certain computers. But since a lot of the computers are in completely different OU's the script doesn't work for all the computers at once.

I've run the script for certain computers, and manually removed the other computers since it was faster than fixing a script to do so for me.

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

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…
Compliance and data security require steps be taken to prevent unauthorized users from copying data.  Here's one method to prevent data theft via USB drives (and writable optical media).
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 from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

650 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