Weak password detection

Source: Internet
Author: User
Tags samaccountname

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.