Computing.Net > Forums > Windows 2000 > Removing old computers from AD

Removing old computers from AD

Reply to Message Icon

Original Message
Name: tadboy
Date: June 16, 2004 at 11:33:09 Pacific
Subject: Removing old computers from AD
OS: Windows XP
CPU/Ram: 1700/256
Comment:

There has to be a quicker way to removing computers that no longer exist from Active Directory. Perhaps something that's automated? Right now I have to manually go through and trace what actually exists and delete manually.

Any help is always appreciated.


Report Offensive Message For Removal

Response Number 1
Name: Jennifer SUMN
Date: June 16, 2004 at 12:31:27 Pacific
Subject: Removing old computers from AD
Reply: (edit)

Remove each one as it's removed from the Domain...


Report Offensive Follow Up For Removal

Response Number 2
Name: tadboy
Date: June 16, 2004 at 14:57:55 Pacific
Subject: Removing old computers from AD
Reply: (edit)

That's still micromanaging, and it doesn't address all those systems that are already present in AD but no longer exist on the network.

Thanks for the attempt, though.


Report Offensive Follow Up For Removal

Response Number 3
Name: josepineda1
Date: June 18, 2004 at 18:28:33 Pacific
Subject: Removing old computers from AD
Reply: (edit)

"There has to be a quicker way..."
There is...there are. One possible solution: a vbscript that queries your domain for computers with machine account passwords that haven't changed in...6 months? a year?whatever criterion works for you.
Here is a sample. In active directory, you should use the LDAP provider instead of the //winnt provider. Modify as needed
****
'---begin script routine
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Dim objFSO, objCompFile, objDCFile, objDomain, objComp, objNTComp
Dim strCompFile, strDCFile
Dim strDomain, strDCList
Dim intSecInADay, intAccountAge
Dim shell

strCompFile = "C:\InactivePCsDeleted.txt"
strDCFile = "C:\DCList.txt"
strDomain = "domain" '-------> enter your domain name here...

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objCompFile = objFSO.OpenTextFile(strCompFile, ForAppending, TRUE)
Set objDCFile = objFSO.OpenTextFile(strDCFile, ForReading)
Set objDomain = GetObject("WinNT://" & strDomain)
set shell = Wscript.CreateObject ("wscript.shell")

objDomain.Filter = Array("Computer")
strDCList = objDCFile.ReadAll()
intSecInADay = 60 * 60 * 24
intAccountAge = 120

For Each objComp In objDomain
Set objNTComp = GetObject("WinNT://" & strDomain & "/" & objComp.Name & "$")
If (objNTComp.PasswordAge > intSecInADay * intAccountAge) Then
If InStr(1, strDCList, objComp.Name, vbTextCompare) = 0 Then
''Call objDomain.Delete("Computer", objComp.Name) 'unremark when ready to delete accounts
objCompFile.Writeline objNTComp.Name & " ----> " & "-- computer account has been deleted"' '& '(objNTComp.PasswordAge/intSecInADay)
shell.Popup objComp.Name & " was deleted. ",1,"FYI..."
End If
End If
Next
Msgbox "Script is done." 'provide feedback to alert admin when script is finished.


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Removing old computers from AD

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software