Thursday, October 17, 2013

Get More Detailed Information Using GetDirectoryEntry()

To get more detailed information about an accounts using GetDirectoryEntry() to turn the search result into actual account objects:
# send LDAP query to Active Directory
$searcher = [ADSISearcher]'(&(objectClass=User)(objectCategory=person)(sAMAccountName=*))' 
# get 10 results max
$searcher.SizeLimit = 10 
# find account location
$searcher.FindAll() |
  # get account object
  ForEach-Object { $_.GetDirectoryEntry() } |
  # display all properties
  Select-Object -Property * |
  # display in a grid view window (ISE needs to be installed for this step)

  Out-GridView

# Joe Piggee

No comments:

Post a Comment