OUs and objects count command

is there an easy way (possibly shell command) to list all OUs in a domain - a count of how many objects are within each of those OU's - and whether or not it is protected from accidental deletion?
LVL 3
pma111Asked:
Who is Participating?
 
SubsunConnect With a Mentor Commented:
Try..
Get-ADOrganizationalUnit -F * -Pr ProtectedFromAccidentalDeletion -ResultSetSize $null  | Select Name, DistinguishedName,ProtectedFromAccidentalDeletion ,@{N="Count";E={(Get-ADObject -SearchBase $_.DistinguishedName -F * -ResultSetSize $null | Measure-Object).Count}} | Export-csv C:\temp\report.csv

Open in new window

Result gives the DN of OU and the total object count in the OU.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.