Active Directory - Paged Queries
One question that has come up a couple of times in the newsgroup 'microsoft.public.windows.powershell' is how to get more than 1000 records from an Active Directory query, particularly when using get-adobject (from the Powershell Community Extensions). Unfortunately, for the moment there is no way to retrieve more records using get-adobject. I'm sure the PSCX team is working to add that for a future release, but in the mean time, here's how you can accomplish the same results using the [directoryservices.directorysearcher] class and the .PageSize property.
$de = [ADSI]''
$ads = new-object directoryservices.directorysearcher
$ads.searchroot = $de
$ads.filter = "(&(objectcategory=person)(objectclass=user))"
$ads.pagesize = 100
$g = $ads.findall()
$g.count
The magic is in the $ads.pagesize = 100 line which tells the query to return up to 100 "pages" of results (with default being 1000 records per page unless you modify a setting on the Domain Controller itself).
The one difference between using directoryservices.directorysearcher and get-adobject is that directorysearcher actually returns a SearchResultCollection. If you want the actual directoryentry (which is what get-adobject returns), you can modify $g = $ads.findall() to:
$g = $ads.findall() | % { $_.GetDirectoryEntry() }
This will fill $g with DirectoryEntry objects instead of just the SearchResult objects.
gaurhoth