Skip to content

Instantly share code, notes, and snippets.

@joe-scalise
Created February 4, 2020 16:07
Show Gist options
  • Select an option

  • Save joe-scalise/77225a7ba8f55a9160c7c385c9cbbc5a to your computer and use it in GitHub Desktop.

Select an option

Save joe-scalise/77225a7ba8f55a9160c7c385c9cbbc5a to your computer and use it in GitHub Desktop.
Simple PowerShell LDAP Query
$user="testerdouglas"
$finalResults = New-Object System.Object
$domain = "LDAP://ldap.example.com/ou=accounts,dc=example,dc=com"
$root = New-Object -TypeName System.DirectoryServices.DirectoryEntry($domain,$null,$null,"Anonymous")
$query = New-Object System.DirectoryServices.DirectorySearcher($root,"(&(objectclass=*)(uid=$($user)))")
$results = $query.findone()
$results.Properties
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment