Why do I get different count values using Get-ADObject and Get-ADUser?

I am having a WTF moment here.

Can someone please explain to me why these two produce different count results.

Thank you very much.

Using Get-ADObject

The following code for my environment produces a value of 2603:

$GetADObject = Get-ADObject -Filter ‘ObjectCategory -eq “User”’

$ADObjectCount = $GetADObject.Count

$ADObjectCount

Using Get-ADUser

The following code for my environment produces a value of 2562

$GetADUser = Get-ADUser -Filter *

$GetADUser.Count

The different number is because the user category contains also computer accounts, not only user accounts. In order to obtain the result you want you have to use ObjectCategory -eq “Person”.

AAHHHHHHH geez, I completely forgot about the “Person” identifier.

Sweet!

Thanks man

Nope, it’s still off by the same values. Anything else it could be?

Should I just go with Get-ADUser instead of Get-ADObject?

Thanks again

To retrieve only user accounts, you need to filter on both objectCategory = ‘Person’ and objectClass = ‘User’. There are probably other combinations which get a similar result, but this is how I learned it, back in the Windows 2000 Active Directory days:

$users = Get-ADObject -Filter 'objectCategory -eq "person" -and objectClass -eq "user"'

Sounds good. Thanks again, Dave