' ' Lists all computer accounts in a domain with the last date of login, in comma ' seperated format. Useful to pipe to a file to open in a spreadsheet. ' domain = "dc=web,dc=mycompany,dc=net" On Error resume Next Dim oUsers,oDCList,ObjConnection,objCommand,domain Set ObjConnection = CreateObject("ADODB.Connection") ObjConnection.Open "Provider=ADsDSOObject;" Set objCommand = CreateObject("ADODB.Command") objCommand.ActiveConnection = ObjConnection objCommand.CommandText = ";(objectCategory=computer);distinguishedName;subtree" Set objList = objCommand.Execute While Not objList.EOF Set oComp = GetObject("LDAP://" & objList.Fields("distinguishedName")) WScript.Echo(Right(oComp.name,(Len(oComp.name)-3)) & "," & oComp.LastLogin) If Err.Number <> 0 Then WScript.Echo(Right(oComp.name,(Len(oComp.name)-3)) & ",-") Err.Clear() End if objList.MoveNext Wend On Error goto 0