$Domain = ‘LDAP://DC=yourdomain;DC=com’
$Root = New-Object DirectoryServices.DirectoryEntry $Domain
$select = New-Object DirectoryServices.DirectorySearcher
$select.SearchRoot = $root
$adobj= $select.findall() |? {$_.properties.objectcategory -match “CN=Person”}
$adobj.count

For the $Domain variable change the “yourdomain” string┬áto the name of your domain.