Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get sub OUs description within a given OU

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

like image 279
miticoluis Avatar asked Nov 16 '25 18:11

miticoluis


1 Answers

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
like image 152
DarkLite1 Avatar answered Nov 18 '25 10:11

DarkLite1



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!