Solved

AD script

Posted on 2011-02-18
4
279 Views
Last Modified: 2012-05-11
I need to query AD and find all user accounts created after a certain date. Can this be done? anyone have a script?
0
Comment
Question by:DEFclub
4 Comments
 
LVL 27

Accepted Solution

by:
KenMcF earned 167 total points
ID: 34927708
I would use the quest AD cmdlets for this.

get-qaduser -createdafter 1/15/2011



http://www.quest.com/powershell/activeroles-server.aspx
0
 
LVL 39

Assisted Solution

by:Krzysztof Pytko
Krzysztof Pytko earned 166 total points
ID: 34927732
You can query AD to text file, import it to Excel and filter result with your criteria. To export that run on a DC or workstation with Administrative Tools/RSAT installed and in command-line type

dsquery * -filter "(&(objectCategory=User)(objectClass=User)(sAMAccountName=*))" -attr givenName sn sAMAccountName whenCreated >>c:\users.txt

Regards,
Krzysztof
0
 
LVL 1

Assisted Solution

by:BKRsupport
BKRsupport earned 167 total points
ID: 34928086
Try this:
change line 1 to the OU and DC enteries to your info: Set oConfig = GetObject("LDAP://OU=ORG UNIT TO QUEREY, dc=DOMAINNAME, dc=LOCAL OR COM"

change line 10 to the date to how many days from today back to look for "If d > Now() - 10 Then" (ie 10 days)

Set oConfig = GetObject("LDAP://OU=ORG UNIT TO QUEREY, dc=DOMAINNAME, dc=LOCAL OR COM")
Set oConn = CreateObject("ADODB.Connection")
oConn.Provider = "ADSDSOObject"
oConn.Open ""

strQuery = "<" & oConfig.adspath & ">;(&(objectClass=user));cn,createTimeStamp;subtree"
Set oRS = oConn.Execute(strQuery)
While Not oRS.EOF
    d = oRS.Fields("createTimeStamp")
    If d > Now() - 10 Then
	 PUT OUTPUT LINE (ie msgbox oRS.Fields("cn"))
   end if
oRS.MoveNext
Wend

oConn.close
set oconfig = nothing
set oconn = nothing

Open in new window

0
 

Author Closing Comment

by:DEFclub
ID: 34928302
all work... thxs
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Resolve DNS query failed errors for Exchange
In this article, I am going to show you how to simulate a multi-site Lab environment on a single Hyper-V host. I use this method successfully in my own lab to simulate three fully routed global AD Sites on a Windows 10 Hyper-V host.
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question