Solved

AD script

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Find out how to use Active Directory data for email signature management in Microsoft Exchange and Office 365.
This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

840 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