使用PowerShell获取所有活动域计算机

时间:2014-03-20 03:29:35

标签: powershell active-directory

我使用此脚本(如下)获取域中的所有计算机;但似乎它停在1000点,当我知道显然有更多。如何获得完整列表?

$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}

1 个答案:

答案 0 :(得分:2)

尝试添加

$objSearcher.PageSize = 2000

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