• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 382
  • Last Modified:

script to list all the sub-OUs under a OUand a total of the objects within these

How can I list all the sub-OUs under a OU and list the total of the objects that might be in those sub-OUs

for instance

OU=world
       OU=europe  20 workstation 15 users
       OU=Asia      15 worlstation 8 users

thanks

0
davidm27
Asked:
davidm27
  • 3
1 Solution
 
davidm27Author Commented:
hi,
I have seen this script the essentially its not far off what i need, i just dont know how to get it to tally up the objects and place them next to there sub ou's as what it does just now basically gives all the objects but doesnt show me what ou they are in.
0
 
Shabarinath RamadasanInfrastructure ArchitectCommented:
Try this code.

You need to have quest power-shell command-lets.

Will list out the OUs in first level and count for users and computers on each OU.

Good luck
Shaba


Get-QADObject -SearchScope "onelevel" -Type 'organizationalUnit' -SearchRoot  "OU=OUNAME, DC=Domain, DC=COM" |foreach  ($_.DN) {((write-output $_.DN),(write-output "User Count"),(Get-QADUser -SearchRoot $_.DN).count),(write-output "Computer Count"), ((get-qadcomputer -searchroot $_.dn).count)}

Open in new window

0
 
davidm27Author Commented:
That works great how would i go about outputting that to a csv file?
thanks
0
 
davidm27Author Commented:
thanks
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now