none
Using DSquery to get computers in a specific OU and not computers in OU's below RRS feed

  • Question

  • For example:

    I have the structure Computers\Staff

    I need to get all the computers in the computers OU and not the computers in Staff

    I'm using

    "dsquery computer ou=computers,dc=op,dc=ac,dc=nz"

    but I still get the computer objects in "ou=staff,ou=computers,dc=op,dc=ac,dc=nz" as well...

    Any help appreciated.

    Thanks.

    Friday, July 23, 2010 5:19 AM

Answers

  • Howdie!
     
    On 23.07.2010 07:19, TURNBE wrote:
    > "dsquery computer ou=computers,dc=op,dc=ac,dc=nz"
    >
    > but I still get the computer objects in
    > "ou=staff,ou=computers,dc=op,dc=ac,dc=nz" as well...
     
    Specify the -scope switch to "onelevel".
     
    Cheers,
    Florian
     

    Microsoft MVP - Group Policy (http://www.frickelsoft.net/blog)
    • Proposed as answer by Meinolf Weber Friday, July 23, 2010 9:13 AM
    • Marked as answer by Bruce-Liu Wednesday, July 28, 2010 8:28 AM
    Friday, July 23, 2010 6:17 AM
  • Hi,

     

    As Florian has stated, you need to add the –scope switch. Please try to use the following command to query:

     

    dsquery computer ou=computers,dc=op,dc=ac,dc=nz -scope onelevel

     

    For more information, please refer to:

     

    Dsquery computer

    http://technet.microsoft.com/en-us/library/cc730720(WS.10).aspx

     

    Regards,

    Bruce

    • Marked as answer by Bruce-Liu Wednesday, July 28, 2010 8:29 AM
    Monday, July 26, 2010 8:48 AM

All replies

  • Howdie!
     
    On 23.07.2010 07:19, TURNBE wrote:
    > "dsquery computer ou=computers,dc=op,dc=ac,dc=nz"
    >
    > but I still get the computer objects in
    > "ou=staff,ou=computers,dc=op,dc=ac,dc=nz" as well...
     
    Specify the -scope switch to "onelevel".
     
    Cheers,
    Florian
     

    Microsoft MVP - Group Policy (http://www.frickelsoft.net/blog)
    • Proposed as answer by Meinolf Weber Friday, July 23, 2010 9:13 AM
    • Marked as answer by Bruce-Liu Wednesday, July 28, 2010 8:28 AM
    Friday, July 23, 2010 6:17 AM
  • Hi,

     

    As Florian has stated, you need to add the –scope switch. Please try to use the following command to query:

     

    dsquery computer ou=computers,dc=op,dc=ac,dc=nz -scope onelevel

     

    For more information, please refer to:

     

    Dsquery computer

    http://technet.microsoft.com/en-us/library/cc730720(WS.10).aspx

     

    Regards,

    Bruce

    • Marked as answer by Bruce-Liu Wednesday, July 28, 2010 8:29 AM
    Monday, July 26, 2010 8:48 AM