Solved

OUs and objects count command

Posted on 2016-09-29
1
42 Views
Last Modified: 2016-10-03
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?
0
Comment
Question by:pma111
1 Comment
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
ID: 41821261
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

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
In this article, I am going to show you how to simulate a multi-site Lab environment on a single Hyper-V host. I use this method successfully in my own lab to simulate three fully routed global AD Sites on a Windows 10 Hyper-V host.
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question