none
How to fetch the list of all users, logon name starts with "a" and should created in between July-11 to Sept-11.

    Question

  • How to fetch the list of all users(Active users), logon name starts with "a" and should created in between July-11 to Sept-11 from Active directory.
    Abhishek
    Monday, November 21, 2011 5:00 PM

Answers

  • Yes.  I forgot that requirement. Thanks for clarifying that Richard.  Here is the updated DSQUERY Command:

    Dsquery * domainroot -filter "(&(objectCategory=Person)(objectClass=User) (sAMAccountName=a*) (whenCreated>=20110711050000.0Z)(whenCreated<=20110912045959.0Z))"

     


    Santhosh Sivarajan | MCTS, MCSE (W2K3/W2K/NT4), MCSA (W2K3/W2K/MSG), CCNA, Network+| Houston, TX
    Blogs - http://blogs.sivarajan.com/

    FaceBook Twitter LinkedIn SS Tech Forum

    This posting is provided AS IS with no warranties,and confers no rights.
    • Proposed as answer by Rich Prescott Monday, November 21, 2011 6:07 PM
    • Marked as answer by Abhishek Tomer Monday, November 21, 2011 6:56 PM
    Monday, November 21, 2011 5:27 PM

All replies

  • How to fetch the list of all users(Active users), logon name starts with "a" and should created in between July-11 to Sept-11 from Active directory.
    Abhishek

    AD Commands:

    dsget /?


    AD PowerShell Module:

    Import-Module ActiveDirectory
    Get-Help Get-ADUser



    Rich Prescott | Infrastructure Architect, Windows Engineer and PowerShell blogger | MCITP, MCTS, MCP

    Engineering Efficiency
    @Rich_Prescott
    Client System Administration tool
    AD User Creation tool
    Monday, November 21, 2011 5:02 PM
  • Try this query using DSQUERY command. 

    Dsquery * domainroot -filter "(&(objectCategory=Person)(objectClass=User)(whenCreated>=20110711050000.0Z)(whenCreated<=20110912045959.0Z))"

    You can convert the time/date using w32tm /ntte command.

    http://social.technet.microsoft.com/wiki/contents/articles/3537.aspx#User


    Santhosh Sivarajan | MCTS, MCSE (W2K3/W2K/NT4), MCSA (W2K3/W2K/MSG), CCNA, Network+| Houston, TX
    Blogs - http://blogs.sivarajan.com/

    FaceBook Twitter LinkedIn SS Tech Forum

    This posting is provided AS IS with no warranties,and confers no rights.
    Monday, November 21, 2011 5:14 PM
  • You can add one additional clause (in parentheses) to the filter Santhosh suggested, to filter on users with "pre-Windows 2000 logon" name that begins with "a":

    (sAMAccountName=a*)

    The filter can be used with any tool that accepts LDAP syntax filters, like dsquery *, and many PowerShell cmdlets. To restrict the query to active users (not disabled), add another clause as follows:

    (!userAccountControl:1.2.840.113556.1.4.803:=2)

    For a full explanation of LDAP syntax filters, see this link:

    http://social.technet.microsoft.com/wiki/contents/articles/5392.aspx#comment-10692

     


    Richard Mueller - MVP Directory Services
    • Proposed as answer by Rich Prescott Monday, November 21, 2011 6:07 PM
    Monday, November 21, 2011 5:21 PM
  • Yes.  I forgot that requirement. Thanks for clarifying that Richard.  Here is the updated DSQUERY Command:

    Dsquery * domainroot -filter "(&(objectCategory=Person)(objectClass=User) (sAMAccountName=a*) (whenCreated>=20110711050000.0Z)(whenCreated<=20110912045959.0Z))"

     


    Santhosh Sivarajan | MCTS, MCSE (W2K3/W2K/NT4), MCSA (W2K3/W2K/MSG), CCNA, Network+| Houston, TX
    Blogs - http://blogs.sivarajan.com/

    FaceBook Twitter LinkedIn SS Tech Forum

    This posting is provided AS IS with no warranties,and confers no rights.
    • Proposed as answer by Rich Prescott Monday, November 21, 2011 6:07 PM
    • Marked as answer by Abhishek Tomer Monday, November 21, 2011 6:56 PM
    Monday, November 21, 2011 5:27 PM