Advertisement
Combreal

simpleLDAPReq01.ps1

Sep 22nd, 2020 (edited)
1,556
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #need empty line at the end
  2. $cred = Get-Credential  -credential conio@ad.dbs.fr
  3. $username = $cred.username
  4. $password = $cred.GetNetworkCredential().password
  5.  
  6. $de = New-Object System.DirectoryServices.DirectoryEntry("LDAP://ad.dbs.fr", $username, $password)
  7.  
  8. $searcher = New-Object System.DirectoryServices.DirectorySearcher($de,"(&(objectCategory=Computer)(CN=mymachine))")
  9.  
  10. $searcher.FindOne().GetDirectoryEntry()
  11.  
  12.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement