dtmDate = Now
strYear = Right(Year(dtmDate), 2)
strMonth = Month(dtmDate)
If Len(strMonth) < 2 Then strMonth = "0" & strMonth
strDay = Day(dtmDate)
If Len(strDay) < 2 Then strDay = "0" & strDay
strStartDate = strYear & strMonth & strDay & "000000Z"
strEndDate = strYear & strMonth & strDay & "235959Z"
strFilter = "(&(createTimeStamp>=" & strStartDate & ")(createTimeStamp<=" & strEndDate & ")(objectCategory=computer))"
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objRootDSE = GetObject("LDAP://RootDSE")
Set objRecordSet = objConnection.Execute( _
"<LDAP://" & objRootDSE.Get("defaultNamingContext") & ">;" & _
strFilter & ";distinguishedName,name,createTimeStamp;subtree")
Set objRootDSE = Nothing
While Not objRecordSet.EOF
dtmCreateTimeStamp = CDate(objRecordSet.Fields("createTimeStamp").Value)
strMessage = objRecordSet.Fields("distinguishedName").Value & VbCrLf & _
objRecordSet.Fields("name") & VbCrLf & _
objRecordSet.Fields("createTimeStamp")
WScript.Echo strMessage
objRecordSet.MoveNext
WEnd
|