Here’s a handy reporting script I found while looking for something else: it shows the number of Users, Contacts and Groups in a OU and sub OU’s.
|What this script does is takes the name of the OU where you want to start the query at as a command-line parameter. It then does an ADSI query to find the distinguished name of the first OU that matches the text entered. It then does 3 separate subtree queries of all the Users, contacts and group objects that are located under the root OU. To group the information that is returned this is where the ADO datashaping provider is used. The information is then stored temporary in a multi dimensional array and then used to finally build a HTM report called ?c:\temp\report.htm? which has a table that shows the OU Name, Description, Path and the number of users, groups and contacts within each OU.The script takes one command-line parameter which is the name of the OU you want to run it against eg to run the script ?cscript.exe lobjectsv2.vbs OUname?. I?ve also created a provision to let the script be run against the entire Active Directory domain instead of just and OU branch to do this instead of using the name of the OU as a command-line parameter use rootdse as the command-line parameter eg ?cscript lobjectsv2.vbs rootdse?