Friday 15 January 2010

Test password has special character in powershell script -


I am trying to create a script which checks that the password has letters and numbers and special characters That's what I've done so far:

  write-output "enter DB password - do not use spaces - any part of the" username "in the" write-output "password Can not include $ Pdb = read-host "At least 1 number in 8 characters and a special character The help should be included @ menow1 "$ string = $ pdb $ pat =" ^ [a-zA-Z0-9 \ s] + $ ". $ Special = [regex]" [^ a-zA-Z0- 9] "} While ($! Pdb- or! ($ Pdb.length -ge 8) -or ($ pdb.Contains ($ pat)) or ($ Pdb.Contains ($ special)))   

This is my most liked. If I input as input cat and press enter then it is indicated again to enter the password. If I put cats in 1234, then it passes And the script ends. I'll signal it again What do I want to do and only if I put cats in $ 1234.

Thanks

Try one:

 < Code> {$ psw = read-host "must contain at least 1 number of 8 characters and one special character i.e. support @ menu 1) while ($ psw.length -lt 8- or $ psw -notmatch '[^ a] -zA-Z0- 9] 'or $ psw -notmatch' \ d ') $ psw    

No comments:

Post a Comment