Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $username = 'aduser'
- $password = 'replaceWithPassword'
- $DomainControllerIpAddress = '192.168.0.21'
- $LdapDn = 'dc=acme,dc=local'
- $dn = New-Object System.DirectoryServices.DirectoryEntry ("LDAP://$($DomainControllerIpAddress):389/$LdapDn",$username,$password)
- # Here look for a user
- $ds = new-object System.DirectoryServices.DirectorySearcher($dn)
- $ds.filter = "((userPrincipalName=*))"
- $ds.SearchScope = "subtree"
- $ds.PropertiesToLoad.Add("distinguishedName")
- $ds.PropertiesToLoad.Add("sAMAccountName")
- $ds.PropertiesToLoad.Add("lastLogon")
- $ds.PropertiesToLoad.Add("telephoneNumber")
- $ds.PropertiesToLoad.Add("memberOf")
- $ds.PropertiesToLoad.Add("distinguishedname")
- $ds.PropertiesToLoad.Add("otherHomePhone");
- $ds.FindAll()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement