locked
get-adcomputer or get-qadcomputer in an ou RRS feed

  • Question

  • how do I get a list of all machines in an ou?

    trying 

    Get-QADComputer -SearchScope "ou=win7,ou=desktops,ou=phase1,dc=domain,dc=com"

    and doesnt work

    Wednesday, July 9, 2014 6:57 PM

Answers

  • That's correct. The -SearchBase parameter is a single string and cannot be a list of different OUs.


    -- Bill Stewart [Bill_Stewart]

    • Proposed as answer by Bill_Stewart Tuesday, July 29, 2014 3:14 PM
    • Marked as answer by Bill_Stewart Monday, August 11, 2014 8:30 PM
    Wednesday, July 9, 2014 7:28 PM

All replies

  • And the error is...?

    Try this:


    get-adcomputer -filter * -searchbase 'OU=win7,OU=desktops,OU=phase1,DC=domain,DC=com'


    -- Bill Stewart [Bill_Stewart]

    Wednesday, July 9, 2014 7:00 PM
  • Hi,

    This is all you need:


    Get-ADComputer -Filter * -SearchBase 'OU=Testing,DC=domain,DC=com'


    Don't retire TechNet! - (Don't give up yet - 12,950+ strong and growing)

    Wednesday, July 9, 2014 7:01 PM
  • thanks I got the order of the OU wrong. 

    another question is how do I combine 2 different searchbase?

    ex:

    OU=Testing,DC=domain,DC=com'

    and

    OU=Testing2,DC=domain,DC=com'

    Wednesday, July 9, 2014 7:10 PM
  • You don't. You have to run the search twice.


    -- Bill Stewart [Bill_Stewart]

    Wednesday, July 9, 2014 7:15 PM
  • you mean I cant do something like

    [PS] C:\Windows\system32>Get-ADComputer -Filter * -SearchBase ("OU=phase1,OU=desktops,OU=win7,DC=domain,DC=com" & "OU=phas
    e1,OU=laptops,OU=win7,DC=domain,DC=com")| select Name

    Wednesday, July 9, 2014 7:25 PM
  • That's correct. The -SearchBase parameter is a single string and cannot be a list of different OUs.


    -- Bill Stewart [Bill_Stewart]

    • Proposed as answer by Bill_Stewart Tuesday, July 29, 2014 3:14 PM
    • Marked as answer by Bill_Stewart Monday, August 11, 2014 8:30 PM
    Wednesday, July 9, 2014 7:28 PM