Solved

Active Directory Reporting

Posted on 2009-04-15
3
314 Views
Last Modified: 2012-05-06
Is there a way of running a report in Active Directory to see all the User Accounts created for 2008?  I can't seem to find an option to do this

Thanks in advance
0
Comment
Question by:Tony
3 Comments
 
LVL 38

Accepted Solution

by:
Shift-3 earned 500 total points
ID: 24149312
Paste the script below into a text file with a .vbs extension.  Customize the value of the strContainer variable on line 5 with the distinguished name of the domain or OU to search under.  Running the script will find all user accounts created in 2008 and write the results to a text file.


On Error Resume Next
 

Const ADS_SCOPE_SUBTREE = 2
 

strContainer = "dc=yourdomain,dc=com"

intYear = 2008

strReport = "report.txt"
 

On Error Resume Next
 

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objReport = objFSO.CreateTextFile(strReport, True)
 

Set objConnection = CreateObject("ADODB.Connection")

Set objCommand =   CreateObject("ADODB.Command")

objConnection.Provider = "ADsDSOObject"

objConnection.Open "Active Directory Provider"

Set objCommand.ActiveConnection = objConnection
 

objCommand.Properties("Page Size") = 1000

objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE 
 

objCommand.CommandText = _

    "SELECT ADSPath FROM 'LDAP://" & strContainer & "' " & _

        "WHERE objectCategory='user'"  

Set objRecordSet = objCommand.Execute
 

objRecordSet.MoveFirst
 

Do Until objRecordSet.EOF

    Set objUser = GetObject(objRecordSet.Fields("ADSPath").Value)

    

    If Year(objUser.WhenCreated) = intYear Then

        objReport.WriteLine objUser.distinguishedName

    End If

    

    objRecordSet.MoveNext

Loop
 

objReport.Close

Open in new window

0
 
LVL 1

Author Closing Comment

by:Tony
ID: 31570498
Thanks!
0
 

Expert Comment

by:Hellbentmaster
ID: 33340241
Hi,

In case the question is still open to anybody, my recommendation is a third party solution called Softerra Adaxes:
http://www.adaxes.com
It includes a vast number of AD reports, and the one particular needed is called "All Users".

Thank you.
0

Join & Write a Comment

On July 14th 2015, Windows Server 2003 will become End of Support, leaving hundreds of thousands of servers around the world that still run this 12 year old operating system vulnerable and potentially out of compliance in many organisations around t…
A quick step-by-step overview of installing and configuring Carbonite Server Backup.
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 …

760 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

20 Experts available now in Live!

Get 1:1 Help Now