Tuesday, June 12, 2012

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-ADOrganizationalUnit -Filter *

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-ADOrganizationalUnit -Filter * | 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-ADOrganizationalUnit -Filter *  -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

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.