Solved

AD script

Posted on 2011-02-18
4
277 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
all work... thxs
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
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…

744 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now