Check the below VBscript and see if that works for you:
Code:
On Error Resume Next
Const ADS_SCOPE_SUBTREE = 2
dtmCreationDate1 = "20110131000000.0Z"
Set objShell = CreateObject("Wscript.Shell")
'Verifies script was run using Cscript, and if not relauches it using Cscript
If Not WScript.FullName = WScript.Path & "\cscript.exe" Then
objShell.Popup "Relaunching script with Cscript in 5 seconds...", 5, _
"Script Host Message", 48
objShell.Run "cmd.exe /k " & WScript.Path & "\cscript.exe //NOLOGO " & _
DQ & WScript.scriptFullName & DQ, 1, False
WScript.Quit 0
End If
'Construct an ADsPath to the Current Domain with rootDSE
Set objRootDSE = GetObject("LDAP://rootDSE")
strADsPath = "LDAP://" & objRootDSE.Get("defaultNamingContext")
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.CommandText = _
"SELECT Name, whenCreated FROM '" & strADsPath & "' WHERE objectClass='user' " & _
"AND whenCreated>='" & dtmCreationDate1 & "'"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
WScript.Echo objRecordSet.Fields("Name").Value, objRecordSet.Fields("whenCreated").Value
objRecordSet.MoveNext
Loop
Bookmarks