$sam=Read-Host "What user account do you want to find?" [ADSISearcher]$searcher="(&(objectcategory=person)(objectclass=user)(sAMAccountname=$sam))" $searcher.pagesize=50 $results=$searcher.FindOne() if ($results.path.length -gt 1) { write $results.path } else { Write-Warning "User $sam was not found." }