Function Find-User { Param ($sam=$(throw "you must enter a sAMAccountname")) [ADSISearcher]$searcher="(&(objectcategory=person)(objectclass=user)(sAMAccountname=$sam))" $results=$searcher.FindOne() if ($results.path.length -gt 1) { write $results } else { write "Not Found" } }