user3203569
user3203569

Reputation: 13

Using PowerShell to get all active-domain computers

I'm using this script(below) to get all computers on the domain; but it seems like it stops at 1000 on the dot, when I know there is clearly more. How would I go about getting the complete list?

$strCategory = "computer"

$objDomain = New-Object System.DirectoryServices.DirectoryEntry

$objSearcher = New-Object System.DirectoryServices.DirectorySearcher
$objSearcher.SearchRoot = $objDomain
$objSearcher.Filter = ("(objectCategory=$strCategory)")

$colProplist = "name"
foreach ($i in $colPropList){$objSearcher.PropertiesToLoad.Add($i)}

$colResults = $objSearcher.FindAll()

foreach ($objResult in $colResults)
{$objComputer = $objResult.Properties; $objComputer.name >> allcomps.csv}

Upvotes: 1

Views: 392

Answers (1)

fuzzybear
fuzzybear

Reputation: 2405

try adding

$objSearcher.PageSize = 2000

http://technet.microsoft.com/en-us/library/ff730959.aspx

Upvotes: 2

Related Questions