locked
List empty OU's RRS feed

  • Question

  • i’m using below query to list empty OU’s fom AD. but its not working :(

    could some one help me ?

    Get-ADObject -Filter {objectclass -eq “OrganizationalUnit”} | Where-Object {@(get-adobject -Filter * -SearchBase $_.DistinguishedName).count -eq 1} | Out-File d:\ou.txt

    Regards, Nidhin.CK

    Tuesday, July 23, 2013 6:07 AM

Answers

  • Get-ADOrganizationalUnit -Filter * |

    Where-Object {-not ( Get-ADObject -Filter * -SearchBase $_.Distinguishedname -SearchScope OneLevel -ResultSetSize 1 )}



    • Edited by Blindrood Tuesday, July 23, 2013 7:00 AM 1234
    • Proposed as answer by Yan Li_ Tuesday, July 23, 2013 7:36 AM
    • Marked as answer by Nidhin CK Tuesday, July 23, 2013 9:11 AM
    Tuesday, July 23, 2013 7:00 AM