Advertisement
private775

PS: Verify login and password ADSI

Jan 8th, 2016
334
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. function checkPass($username, $password){
  3.  
  4.  # Get current domain using logged-on user's credentials
  5.  $CurrentDomain = "LDAP://" + ([ADSI]"").distinguishedName
  6.  $domain = New-Object System.DirectoryServices.DirectoryEntry($CurrentDomain,$UserName,$Password)
  7.  
  8. if ($domain.name -eq $null)
  9. {
  10.  write-host "---- $($username): Authentication failed - please verify your username and password."
  11.  # exit #terminate the script.
  12. }
  13. else
  14. {
  15.  write-host "+++++ $($username): Successfully authenticated with domain $($domain.name)"
  16. }
  17.  
  18. }
  19.  
  20. get-spmanagedaccount | % { $_.UserName } | % { checkPass $_ xxxx }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement