Advertisement
Guest User

Untitled

a guest
Apr 10th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. $username = 'aduser'
  2. $password = 'replaceWithPassword'
  3. $DomainControllerIpAddress = '192.168.0.21'
  4. $LdapDn = 'dc=acme,dc=local'
  5. $dn = New-Object System.DirectoryServices.DirectoryEntry ("LDAP://$($DomainControllerIpAddress):389/$LdapDn",$username,$password)
  6.  
  7. # Here look for a user
  8. $ds = new-object System.DirectoryServices.DirectorySearcher($dn)
  9. $ds.filter = "((userPrincipalName=*))"
  10. $ds.SearchScope = "subtree"
  11. $ds.PropertiesToLoad.Add("distinguishedName")
  12. $ds.PropertiesToLoad.Add("sAMAccountName")
  13. $ds.PropertiesToLoad.Add("lastLogon")
  14. $ds.PropertiesToLoad.Add("telephoneNumber")
  15. $ds.PropertiesToLoad.Add("memberOf")
  16. $ds.PropertiesToLoad.Add("distinguishedname")
  17. $ds.PropertiesToLoad.Add("otherHomePhone");
  18. $ds.FindAll()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement