Submitted By: tabethena

Uses a pair of text files to select and update computer descriptions.

Visual Basic
Edit|Remove
On error resume next
Const conForReading=1, conForWriting=2, conForAppending=8
Const conTriStateFalse=0, conTriStateTrue=-1, conTriStateUseDefault=-2

set ObjFSO = CreateObject("scripting.filesystemobject")
set objPCList = objFSO.OpenTextFile("PCList.txt",conForReading,false,conTriStateUseDefault)
set objDescription = objFSO.OpenTextFile _
    ("description.txt",conForReading,false,conTriStateUseDefault)

setobjFSO = objFSO.OpenTextFile("Log.txt",conForWriting,True,conTriStateUseDefault)

set objShell = CreateObject("WScript.Shell")
set colPC = getObject("LDAP://ou=Computers,ou=My,Company,dc=org")
colPC.Filter = Array("Computer")

Do While Not objDescription.AtEndofStream
     strPCName = objPCList.ReadLine
     strPCdescription = objDescription.ReadLine

	for each objComp in colPC
		If (objComp.CN = strPCName) then
			objComp.Put "Description", strPCdescription 
			objComp.SetInfo
		End if
	
	next
loop

MsgBox "Done"