Search active directory by Date Created

Posted on 2009-12-21
Last Modified: 2012-05-08
I need to search an active directory for objects created recently, Is there such a way?

SBS 2003
Question by:GraemeEvans1
    LVL 16

    Expert Comment

    by:Ady Foot
    Take a look at this article which should help you.  Please shout back if you need any further help.


    LVL 24

    Expert Comment

    For this to know you able to enable auditing on the Domain controller server & if you have enabled auditing,security log will be logged with the event id.
    Admanager plus is also good tool.
    LVL 17

    Accepted Solution

    Below script will help you...!

    Modify the date:
    This denotes Objects created between 01/12/2009 and 31/Dec/2009.

    dtmCreationDate1 = "20091201000000.0Z"
    dtmCreationDate2 = "20091231000000.0Z"

    Also modify Domain to your domain
    On Error Resume Next
    dtmCreationDate1 = "20091201000000.0Z"
    dtmCreationDate2 = "20091231000000.0Z"
    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 Name, whenCreated FROM 'LDAP://dc=india,dc=microsoft,dc=com' WHERE objectClass='user' "  & _
            "AND whenCreated>='" & dtmCreationDate1 & "' AND whenCreated<='" & dtmCreationDate2 & "'" 
    Set objRecordSet = objCommand.Execute
    Do Until objRecordSet.EOF
        Wscript.Echo objRecordSet.Fields("Name").Value, objRecordSet.Fields("whenCreated").Value

    Open in new window

    LVL 17

    Expert Comment

    by:Premkumar Yogeswaran
    I am using the above script for the same. I beleive it will work great for you.
    LVL 17

    Expert Comment

    by:Premkumar Yogeswaran
    Modify the date and domain then Save this vbscript(Objectdate.vbs).
    And open this script via Cscript.
    Start run CMD enter
    c:\>cscript objectdate.vbs
    It will give a list..!

    If you want the date of the object created
    In ADUC
    View -> Advanced option
    Now search for the object found in the list in ADUC.
    You can find the additional tab "Object" in users property. in that tab you can find the date of object created.
    LVL 4

    Author Closing Comment

    Great Script

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Do you have users whose passwords are expiring and they are constantly calling you?  Well I sure did and needed a way to put an end to this.  We have a lot of remote users which would not be notified that their passwords were expiring since they wer…
    I’m often asked about newer and larger USB drives connected to SBS2008 and 2011 failing Windows Server Backup vs the older USB drives not failing. As disk space continues to grow and drive technology change SBS2008 and some SBS2011 end up with the f…
    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 from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…

    731 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

    15 Experts available now in Live!

    Get 1:1 Help Now