Solved

Find OU with most computers in Active Directory

Posted on 2009-03-30
6
491 Views
Last Modified: 2012-05-06
Is there an easy way to find out which OU in Active Directory contains the most computers?

What about just a report of some kind to show the # of computers based on the container they're in, instead of a just a long list of all computers in Active Directory?

Using Windows XP and active directory is on windows 2003 server
0
Comment
Question by:garryshape
  • 3
  • 2
6 Comments
 
LVL 57

Expert Comment

by:Mike Kline
Comment Utility
I use a tool called adfind to get the counts
http://www.joeware.net/freetools/tools/adfind/index.htm
So for the domain for instance
adfind -b dc=yourdomain,dc=com -f "objectcategory=computer" -c
I'm not sure if it can go and count per OU but I'll test and if I find a way using adfind I'll let you know
Thanks
Mike
 
0
 
LVL 70

Accepted Solution

by:
Chris Dent earned 500 total points
Comment Utility

PowerShell can though with a small amount of code.

You'd need this;

http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx

And this:

http://www.quest.com/activeroles-server/arms.aspx

To be able to run the little script below (it'll just paste into the Quest PowerShell window).

Chris
Get-QADObject -Type OrganizationalUnit | %{

  $ComputerCount = (Get-QADObject -SearchRoot $_.DN -Type Computer -Scope OneLevel).Count

  If ($ComputerCount) { $_ | Select-Object DN, @{n='ComputerCount';e={ $ComputerCount }} } }

Open in new window

0
 
LVL 70

Expert Comment

by:Chris Dent
Comment Utility

The second "GetQAD-Object" should have been substituted with Get-QADComputer as below. Although it really doesn't make much difference.

Chris
Get-QADObject -Type OrganizationalUnit | %{

  $ComputerCount = (Get-QADComputer -SearchRoot $_.DN -Scope OneLevel).Count

  If ($ComputerCount) { $_ | Select-Object DN, @{n='ComputerCount';e={ $ComputerCount }} } }

Open in new window

0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 57

Expert Comment

by:Mike Kline
Comment Utility
I had a feeling powershell could do it
Ok going to see Brandon speak in April. I'm going to get the powershell bug :)
0
 
LVL 70

Expert Comment

by:Chris Dent
Comment Utility

Sounds like fun, I hope you get a lot out of it :)

Chris
0
 

Author Closing Comment

by:garryshape
Comment Utility
Thanks it works great
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Mapping Drives using Group policy preferences Are you still using old scripts to map your network drives if so this article will show you how to get away for old scripts and move toward Group Policy Preference for mapping them. First things f…
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now