Scripting – Boolean with If statements problem. defaults to does not meet the criteria. even when one digit and one upper and lowercase letter is entered

for some reason when i validate my password even when it require a digit, uppercase and lowercase. It defaults to doesn’t meet the crtieria and i dont know why since i return the new boolean. Any help/advice is much appreciated. thank you.

$userpassword = Read-Host “Please Enter A Password”

$Boolean = $false

function Checkpassword ($userpassword){

if ($userpassword -match “w” -and ($userpassword.Length -ge 15)){

$Boolean = $True

}

else{

$Boolean = $false

}

Return $Boolean

}

Checkpassword($userpassword)

if ($Boolean -eq “$True”){

write-host “This is A Valid Password”}

else{

write-output “This does not meet the criteria for the Password”

}

submitted by /u/Niallirishman
[link] [comments]

Leave a Reply