20 lines
488 B
PowerShell
20 lines
488 B
PowerShell
# PowerShell Password Policy Checker
|
|
|
|
$password = Read-Host "Enter a password"
|
|
|
|
if ([string]::IsNullOrEmpty($password)) {
|
|
Write-Host "You must enter a password"
|
|
exit
|
|
}
|
|
|
|
$hasLetter = $password -match "[a-zA-Z]"
|
|
$hasDigit = $password -match "[0-9]"
|
|
$hasSpecial = $password -match "[^a-zA-Z0-9]"
|
|
$longEnough = $password.Length -ge 12
|
|
|
|
if ($hasLetter -and $hasDigit -and $hasSpecial -and $longEnough) {
|
|
Write-Host "Password is strong"
|
|
} else {
|
|
Write-Host "Password is weak"
|
|
}
|