?
Solved

AD script

Posted on 2011-02-18
4
Medium Priority
?
287 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 27

Accepted Solution

by:
KenMcF earned 668 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 664 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 668 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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Uncontrolled local administrators groups within any organization pose a huge security risk. Because these groups are locally managed it becomes difficult to audit and maintain them.
Compliance and data security require steps be taken to prevent unauthorized users from copying data.  Here's one method to prevent data theft via USB drives (and writable optical media).
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 configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …
Suggested Courses

770 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