DSQuery

Discussion in 'Software' started by Theprof, Apr 12, 2012.

  1. Theprof

    Theprof Petabyte Poster

    4,607
    83
    211
    Hey guys,

    Quick question, does anyone know the proper dsquery/dsget command to pull up all users in AD that are enabled only and not include disabled users? I have the command to pull all the users and the command to pull only disabled users... I also need it to display the title/department attribute. Here's the command that I used:

    dsquery * -filter "(&(objectcategory=person)(objectclass=user))" -limit 0 -attr samaccountname description department title >> exportedusers.txt

    Somehow I need to incorporate an exclusion to in that string to not pull disabled accounts. There's probably a way to do it with a VB script but I am hoping something can be done with dsquery or dsget.
     
    Certifications: A+ | CCA | CCAA | Network+ | MCDST | MCSA | MCP (270, 271, 272, 290, 291) | MCTS (70-662, 70-663) | MCITP:EMA | VCA-DCV/Cloud/WM | VTSP | VCP5-DT | VCP5-DCV
    WIP: VCAP5-DCA/DCD | EMCCA
  2. Theprof

    Theprof Petabyte Poster

    4,607
    83
    211
    Never mind, figured it out... I used the following command:

    dsquery * -filter "(&(objectCategory=person)(objectClass=user)(!userAccountControl:1.2.840.113556.1.4.803:=2))" -limit 0 -attr samaccountname department title >>exported.txt
     
    Certifications: A+ | CCA | CCAA | Network+ | MCDST | MCSA | MCP (270, 271, 272, 290, 291) | MCTS (70-662, 70-663) | MCITP:EMA | VCA-DCV/Cloud/WM | VTSP | VCP5-DT | VCP5-DCV
    WIP: VCAP5-DCA/DCD | EMCCA
  3. SimonD
    Honorary Member

    SimonD Terabyte Poster

    3,681
    440
    199
    Or do it through SCCM ;)
     
    Certifications: CNA | CNE | CCNA | MCP | MCP+I | MCSE NT4 | MCSA 2003 | Security+ | MCSA:S 2003 | MCSE:S 2003 | MCTS:SCCM 2007 | MCTS:Win 7 | MCITP:EDA7 | MCITP:SA | MCITP:EA | MCTS:Hyper-V | VCP 4 | ITIL v3 Foundation | VCP 5 DCV | VCP 5 Cloud | VCP6 NV | VCP6 DCV | VCAP 5.5 DCA
  4. Theprof

    Theprof Petabyte Poster

    4,607
    83
    211
    :D I could definitely... but the consulting place I am at don't use SCCM :) My previous place did!
     
    Certifications: A+ | CCA | CCAA | Network+ | MCDST | MCSA | MCP (270, 271, 272, 290, 291) | MCTS (70-662, 70-663) | MCITP:EMA | VCA-DCV/Cloud/WM | VTSP | VCP5-DT | VCP5-DCV
    WIP: VCAP5-DCA/DCD | EMCCA

Share This Page

Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.