CheckADPassword.ps1 896 B

12345678910111213141516171819202122
  1. While(0 -lt 1)
  2. {
  3. Function Test-ADAuthentication {
  4. param($username,$password)
  5. (new-object directoryservices.directoryentry "",$username,$password).psbase.name -ne $null
  6. }
  7. Write-Host -ForegroundColor Yellow "...::: Outil de vérification de mot de passe Active Directory :::..."
  8. $login = Read-Host "Quel est l'identifiant de la session ?"
  9. $password = Read-Host "Quel est le mot de passe de la session ?"-AsSecureString
  10. $password = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($password)
  11. $password = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($password)
  12. $result = Test-ADAuthentication "$login" "$password"
  13. If($result -eq "True")
  14. {
  15. Write-Host -ForegroundColor Green "Le mot de passe AD est correct !"
  16. }else{
  17. Write-Host -ForegroundColor Red "Le mot de passe AD est incorrect."
  18. }
  19. }