private775 icon

PS: Verify login and password ADSI

private775 | PRO | 01/08/16 10:40:10 PM UTC | 0 ⭐ | 714 👁️ | Never ⏰ | []
PowerShell |

600 B

|

None

|

0 👍

/

0 👎

 
function checkPass($username, $password){
 
 # Get current domain using logged-on user's credentials
 $CurrentDomain = "LDAP://" + ([ADSI]"").distinguishedName
 $domain = New-Object System.DirectoryServices.DirectoryEntry($CurrentDomain,$UserName,$Password)
 
if ($domain.name -eq $null)
{
 write-host "---- $($username): Authentication failed - please verify your username and password."
 # exit #terminate the script.
}
else
{
 write-host "+++++ $($username): Successfully authenticated with domain $($domain.name)"
}
 
}
 
get-spmanagedaccount | % { $_.UserName } | % { checkPass $_ xxxx }

Comments