Finding AD Accounts Easily

by Jul 16, 2014

All PowerShell versions

You do not necessarily need additional cmdlets to search for user accounts or computers in your Active Directory. Provided you are logged on to the domain, simply use this:

$ldap = '(&(objectClass=computer)(samAccountName=dc*))'
$searcher = [adsisearcher]$ldap


This would find all computer accounts that start with “dc”. $ldap can be any valid LDAP query. To find users, replace “computer” by “user”.

Twitter This Tip! ReTweet this Tip!