Solved

Find OU with most computers in Active Directory

Posted on 2009-03-30
6
493 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
ID: 24019518
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
ID: 24019588

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
ID: 24019613

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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
LVL 57

Expert Comment

by:Mike Kline
ID: 24019634
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
ID: 24019647

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

Chris
0
 

Author Closing Comment

by:garryshape
ID: 31564329
Thanks it works great
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

920 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

15 Experts available now in Live!

Get 1:1 Help Now