4

Is there any simple way of getting a list of all the OUs located one level under a given OU?

i.e. I have an OU called "Clients" and one level under this OU there are multiple OUs , one for each client. i.e. CAS, ADI, PMA

I would like to get a list with the description of these sub OUs. Following the previous example, the result would be: "Casio, Adidas, Puma"

I tried Get-ADOrganizationalUnit but I couldn't figure out a way of doing this.

Thanks

Josh Crozier
  • 233,099
  • 56
  • 391
  • 304
miticoluis
  • 511
  • 2
  • 15
  • 32

1 Answers1

7

Would this help you out:

$OU = 'OU=Europe,OU=World,DC=domain,DC=net'

Get-ADOrganizationalUnit -SearchBase $OU -SearchScope Subtree -Filter * | 
     Select-Object DistinguishedName, Name

You can find information on how to use the CmdLet Get-ADOrganizationalUnit by typing:

help Get-ADOrganizationalUnit -Example
DarkLite1
  • 13,637
  • 40
  • 117
  • 214
  • Unfortunately it doesn't, It is showing all the subOU names within the given OU. I just want the first level subOUs (the ones that are immedialy one level under the given OU) I should have specified that, my apologies. And I am also getting the actual parent OU listed. I don't want that. – miticoluis Oct 27 '15 at 12:06
  • 3
    I got it, Get-ADOrganizationalUnit -SearchBase $OU -SearchScope Onelevel -Filter * | Select-Object DistinguishedName, Name Thanks a lot – miticoluis Oct 27 '15 at 12:11
  • You're welcome :) Usually, you can find the options in the help. Good work! The more you explore, the more you'll love to use PowerShell. – DarkLite1 Oct 27 '15 at 12:12