April 7, 2010

How to search for an object in Active Directory in a particular OU

$root = [System.DirectoryServices.DirectoryEntry] "LDAP://OU=Employes,DC=dept,DC=company,DC=com"
$search = [ADSISearcher] $root
$search.Filter = "(cn=myUserName)"
$result = $search.FindOne()
$result.properties

No comments:

Post a Comment