Powershell to get LDAP Path of the User

$UserName = “username”

$searcher = new-object DirectoryServices.DirectorySearcher([ADSI]””)

$searcher.filter = “(&(objectClass=user)(sAMAccountName= $UserName))”

$founduser = $searcher.findOne()

$P = $founduser | select path
$p.path

One thought on “Powershell to get LDAP Path of the User

Leave a comment