Active Directory · PowerShell

Powershell and Active Directory: Find all organizational unit containers [OU] in Active Directory using Powershell.

 

Hi,

These days i think i am only and only working with Active Directory.  My Manager give me the task to show him the all Organizational Unit Container , so that we can re-arrange them and remove the OU those are not required any longer.

Seriously i don’t know any way to do this. I never heard about it and never tried it before. Why ? my manager needs it ? that the first thought came in my mind, but buddy manager is a manager ;o) , i have to do it what he said.

The again i decide lets explore some Active Directory cmdlets and see if it have something.

In first attempt i found a single cmdlet which is able to do this. That is  Get-ADOrganizationalUnit

Let’s Start.

 Make sure you have “RSAT installed on you laptop.

Now Import the Active Directory module.

Import-Module ActiveDirectory

30-04-2012 23-21-03 

..

ok, Module is imported,

First run the to view all OUs run the single cmdlet with Filter * parameters

Get-ADOrganizationalUnitFilter *

It is showing us the details of all OUs.

New Delhi Powershell User Group

But i am still not satisfy with the result. let it filter more ,,

Get-ADOrganizationalUnitFilter * | Select Name

I tried to select Name but the output is not so good. Because we can see Name but for example in below screenshot i have multiple OU container named as Users

12-06-2012 11-35-36

ok…still not happy.

let run another command

Get-ADOrganizationalUnitFilter *  properties * | Select CanonicalName

This command will show is a full path of our OUs.

12-06-2012 11-38-05

All Done 🙂

My Target of the day i achieved. Now can do facebook ;o) ;o)

Thanks for reading

Thanks!

Aman Dhally

Buy-More-Twitter-Followers   4fb29548b6adc

simba

6 thoughts on “Powershell and Active Directory: Find all organizational unit containers [OU] in Active Directory using Powershell.

  1. why not use:

    Get-ADOrganizationalUnit -Filter * -properties * | Select DistinguishedName

    I think a DN is more useful than the canonical name.

    1. Hi Harold,

      Nice idea.
      I think, there is always more then one way to accomplish the same thing. 🙂

      Regards
      Aman Dhally

  2. hi
    good jobs how I can create many OUs in AD and after this create many or one group for each ou from list liste file content the name of OUs and content the name list of group
    Thanks

Comments are closed.