Welcome to Powergui.org - an open source community for Windows Powershell

PowerGUI.org PowerGUI.org and blogs

Forums » Active Directory and PowerShell

Thread: AD Tricks: How many objects do you have in your AD, part 1


Permlink Replies: 0 - Pages: 1
Andrei Polevoi [Quest]


Posts: 969
Registered: 8/9/06
AD Tricks: How many objects do you have in your AD, part 1
Posted: Apr 16, 2007 11:51 AM
  Click to reply to this thread Reply

(This post providesinformation on how you can use Management Shell for AD from Quest Software todo various management tasks for your Active Directory. For a quick introductioninto Management Shell for AD, please refer to: http://powergui.org/thread.jspa?threadID=2700&tstart=0)

 

If you havemore then 1000 users in your AD domain, the Get-QADUser will not display themall. There is a default limit on items to display in Get-QAD* results and thelimit is 1000. To display all objects in AD, use -SizeLimit parameter (or -slas alias):

Get-QADUser-sl 1000000

 

 

To countobjects, use Measure-Object built-in cmdlet:

PSC:\> Get-QADUser -sl 1000000 | Measure-Object

 

Count    : 4325

Average  :

Sum      :

Maximum  :

Minimum  :

Property:

 

So, we havetotal 4325 user accounts in domain.

It mighttake some time to execute this, as PowerShell first load all users from AD,then count them.

 

To display countonly, use Format-Table or Format-List built-in cmdlet and select required propertyfrom the pipe. We will use Format-List for more friendly presentation:

PSC:\> Get-QADUser -sl 1000000 | Measure-Object | Format-List Count

 

Count: 4325

 

Now let'scount groups:

PSC:\> Get-QADGroup -sl 1000000 | Measure-Object | Format-List Count

 

Count: 3948

 

To countobjects of any type, use Get-QADObject cmdlet. Let's count OUs:

PS C:\>Get-QADObject -sl 100000 -type organizationalUnit | Measure-Object |Format-List Count

 

Count : 135

 



Regards,
Andrei [Quest]
This posting is provided "AS IS" with no warranties, and confers no rights

Legend
MVP: 2501 + pts
Guru: 2001 - 2500 pts
Expert: 751 - 2000 pts
Enthusiast: 31 - 750 pts
Novice: 0 - 30 pts
Moderators
Helpful answer (5 pts)
Answered (10 pts)

Point your RSS reader here for a feed of the latest messages in all forums