Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $pswCharacters = 7
- $pswDigits = 4
- $pswSpecialChars = @("!","@","$")
- $pswUseSpecialChars = $true
- function fnc_randomPsw
- {
- $constants = ('b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z')
- $vowels = ('a', 'e', 'i', 'o', 'u')
- $pswWord = ""
- $useConstant = $true
- for ($i = 1; $i -le $pswCharacters; $i++)
- {
- if ($useConstant)
- {
- $pswWord += Get-Random -InputObject $constants
- $useConstant = $false
- }
- else
- {
- $pswWord += Get-Random -InputObject $vowels
- $useConstant = $true
- }
- }
- $pswWordUpper = $pswWord[0].ToString().ToUpper()
- $pswWordFinal = $pswWordUpper + $pswWord.ToString().Remove(0, 1)
- if ($pswUseSpecialChars)
- {
- $pswWordFinal += (Get-Random -InputObject $pswSpecialChars).ToString()
- }
- $pswNmbrs = ""
- for ($i = 1; $i -le $pswDigits; $i++)
- {
- $pswNmbrs += (Get-Random -Minimum 0 -Maximum 9).ToString()
- }
- $pswWordFinal += $pswNmbrs
- return $pswWordFinal
- }
- fnc_randomPsw
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement