-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.ps1
24 lines (19 loc) · 978 Bytes
/
functions.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Create a Function to ensure a strong certificate password is used.
function StrongPassword {
do {
$password = Read-Host "-ENTER A SECURE CERTIFICATE PASSWORD-`n`nYour password must meet the following requirements:
`n`nAt least one upper case letter [A-Z]`nAt least one lower case letter [a-z]`nAt least one number [0-9]`nAt least one special character (!,@,#,%,^,&,$,_)`nPassword length must be 7 to 25 characters.`n`n`nEnter a certificate password"
if(($password -cmatch '[a-z]') -and ($password -cmatch '[A-Z]') -and ($password -match '\d') -and ($password.length -match '^([7-9]|[1][0-9]|[2][0-5])$') -and ($password -match '!|@|#|%|^|&|$|_'))
{
Write-Host "`nYour certificate had been saved with your selected password!`n"
$valid = "True"
return $password
}
else
{
Write-Host "`nThe password you entered is invalid!`n"
}
} until (
$valid -eq "True"
)
}