Add-Type -AssemblyName Microsoft.VisualBasic
$UserName = [Microsoft.VisualBasic.Interaction]::InputBox('Compte utilisateur (SAM):', 'Utilisateur', "Saisissez un nom d'utilisateur")
$Password = [Microsoft.VisualBasic.Interaction]::InputBox('Mot de passe):', 'Mot de passe', "Saisissez le mot de passe")
Function Test-ADAuthentication {
param(
$username,
$password)
(New-Object DirectoryServices.DirectoryEntry "",$username,$password).psbase.name -ne $null
}
$resultat = Test-ADAuthentication -username $UserName -password $password
If($resultat -eq "True")
{
Add-Type -AssemblyName PresentationCore,PresentationFramework
$ButtonType = [System.Windows.MessageBoxButton]::OK
$MessageIcon = [System.Windows.MessageBoxImage]::Information
$MessageBody = "Le mot de passe est correct"
$MessageBody2
$MessageTitle = "Information"
$Result = [System.Windows.MessageBox]::Show($MessageBody,$MessageTitle,$ButtonType,$MessageIcon)
}else{
Add-Type -AssemblyName PresentationCore,PresentationFramework
$ButtonType = [System.Windows.MessageBoxButton]::OK
$MessageIcon = [System.Windows.MessageBoxImage]::Information
$MessageBody = "Le mot de passe est incorrect"
$MessageBody2
$MessageTitle = "Information"
$Result = [System.Windows.MessageBox]::Show($MessageBody,$MessageTitle,$ButtonType,$MessageIcon)
}