Count Objects in AD OUs – Powershell

A recent request we had was to count the number of objects in each OU in AD, so we could identify which ones were not being used any more. To achieve this we used a PowerShell script, and exported to a csv file.

I have seen a number of scripts that will count the number of Users, Computers or Groups in an OU, but we wanted to combine these, so we can see both object counts in one report.

This gives you a great output of both the Users, Computers or Groups in each OU in your domain, including both Enabled and Disabled counts.


    1. Hi Florian,
      Are you just looking to get the number of Users and Computers that are members of the Groups you have listed in a csv file?

  1. awesome, thank you Ashley. added another line to search for distro and edited existing to give security, changed scope to 2 and got what I needed in minutes 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *