Solved

Find OU with most computers in Active Directory

Posted on 2009-03-30
6
494 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
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 
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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Map drive based on local server 5 36
Enable ad recycle bin 1 16
Active Directory uninstall Windows 2008 R2 6 85
SharePoint Explorer Folder Access 4 37
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.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

777 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