Solved

AD script

Posted on 2011-02-18
4
282 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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Always backup Domain, SYSVOL etc.using processes according to Microsoft Best Practices. This is meant as a disaster recovery process for small environments that did not implement backup processes and did not run a secondary domain controller that ne…
Active Directory security has been a hot topic of late, and for good reason. With 90% of the world’s organization using this system to manage access to all parts of their IT infrastructure, knowing how to protect against threats and keep vulnerabil…
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…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

726 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