Google Reviews
If you find this content or our services useful, please leave us a review.

Other Posts in this Series:

This post provides a simple example of how we can use ADSI to search computers in Active Directory.  You may wish to further optimise this by using LDAP filters.

#only computers
$objSearcher=[adsisearcher]'(&(objectCategory=computer))'
$objSearcher.PageSize = 200

#specify properties to include
$colProplist = "name"
foreach ($i in $colPropList) { $objSearcher.PropertiesToLoad.Add($i) | out-null } 
	
$colResults = $objSearcher.FindAll()

foreach ($objResult in $colResults)
{
    #computer name
    $assetname = ($objResult.Properties).name    
    write-host $assetname  		
}
Use ADSI to Search Computers in Active Directory
Comments have now been disabled. If you have a question to ask about this post please ask the community!