Link to home
Start Free TrialLog in
Avatar of amazon4life
amazon4life

asked on

PowerShell Script - Count OUs within a specific domain

Does anyone have a PowerShell Script that can list a count of all objects within the per-OU in a specific domain?
Avatar of Ed OConnor
Ed OConnor
Flag of Ireland image

How about this for starters:

Set-Location AD:
(Get-ChildItem "OU=Users,OU=Accounts,DC=domain,DC=com" | select).Count

Open in new window


Just change the DN as needed...  Are you looking for something more flexible?
Absolutely, but can you be a bit more specific about what you need?  Do you need to count all the containers in a specific OU?  All the users& groups in a specific OU?  Any recursive objects (users, groups, contacts, shared folders)?  etc etc
ASKER CERTIFIED SOLUTION
Avatar of it_saige
it_saige
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That is wonderful Richard :-)