import-Module ActiveDirectory$file="E:\PowerShell\Checkpass\ausersy.txt"$file _output="E:\PowerShell\Checkpass\badpass.txt"$usersy=get-aduser-Filter*-searchbase"ou=, dc=uxin,dc=youxinpai,dc=com"$usersy|%{$_. samaccountname|out-file $file-append-encoding UTF8}start-sleep-s 1Functiontest-adauthentication {param($username,$password) (New-object Directoryservices.directoryentry"",$username,$password). Psbase.name-ne $null}$domain="xxx.com"$data= GC$fileforeach($row inch $data) { $username=$row $password="[email protected]" if(test-adauthentication"$domain \ $username" "$password") {Write-host"$username:: Old Password"-foregroundcolor"Red" $username|out-file $file _output-Append}Else{Write-host"$username:: not"-foregroundcolor"Green" }}
V2.0:
import-Module ActiveDirectory$file="E:\PowerShell\Checkpass\ausersy.txt" #Export AD User$file _output="E:\PowerShell\Checkpass\badpass.txt" #Output Weak pass account$weakpass _file="E:\PowerShell\Checkpass\weakpass.txt" #Save Weak password$usersy=get-aduser-Filter*-searchbase"ou=yy,dc=u,dc=yy,dc=com"$domain="x.com"if(Test-path$file) {Remove-item$file}#Exporting AD usersforeach($user inch $usersy){$user. samaccountname|out-file $file-append-encoding UTF8}start-sleep-s 1#detect if the password is normalFunctiontest-adauthentication {param($username,$password) (New-object Directoryservices.directoryentry"",$username,$password). Psbase.name-ne $null}$data= GC$file$weakpasses= GC$weakpass _fileforeach($row inch $data) { $username=$row foreach($password inch $weakpasses) { if(test-adauthentication"$domain \ $username" "$password") {Write-host"$username bad password: $password"-foregroundcolor"Red" $username+" : "+$password|out-file $file _output-Append}Else{Write-host"$username:: OK"-foregroundcolor"Green" } } }
Weak password detection