So i am trying to make a variable match the password requirements for making a virtual machine in azure CLI
to do this it must have 3 of the following !uppercase, 1 lowercase 1 special character or a number
This is the main code i am trying to change
$AdminPassword = Read-Host -Prompt "Please insert a Admin Password (Password must have 3 of the following: 1 lower case character, 1 upper case character, 1 number and 1 special character)"
This is the code i changed but isn't working correctly
do
{
$AdminPassword = Read-Host -Prompt "Please insert a Admin Password (Password must have the 3 of the following: 1 lower case character, 1 upper case character, 1 number and 1 special character)"
}
until($AdminPassword -Like "[A-Z][A-Z][A-Z][a-z][a-z][a-z][0-9][0-9][0-9][!@$#$%^&*()_+\-=\[\]{};'':"\\|,.<>\/? ][!@$#$%^&*()_+\-=\[\]{};'':"\\|,.<>\/? ][!@$#$%^&*()_+\-=\[\]{};'':"\\|,.<>\/? ]")
Write Match
with the write match line i know when it succeeds
the real trouble i have here is that i want all 4 of the requirements 3 times so 3 uppercase's 3 lowercase's etc and i also want to have the special characters but the # comments all the code that follows out
thanks in advance for reading this and posting your anwser!!!
I'm not sure if this can be done with just one regex.. As an alternative, below a small helper function to do the tests.
For the special characters,the regular expression should be the one in the code below.
You need to use single quote for your regular expression:
Test result as below: