Function Get-RandomPassword {
param(
$length = 10,
$characters = 'abcdefghkmnprstuvwxyzABCDEFGHKLMNPRSTUVWXYZ123456789!"??$%&/()=?*+#_'
)
$random = 1..$length | ForEach-Object { Get-Random -Maximum $characters.length }
$private:ofs=""
[String]$characters[$random]
}
Function Randomize-Text {
param(
$text
)
$number = $text.length -1
$indexes = Get-Random -InputObject (0..$number) -Count $number
$private:ofs=''
[String]$text[$indexes]
}
Function Get-ComplexPassword {
$password = Get-RandomPassword -length 8 -characters 'abcdefghiklmnprstuvwxyz'
$password += Get-RandomPassword -length 2 -characters '#*+)'
$password += Get-RandomPassword -length 4 -characters '123456789'
$password += Get-RandomPassword -length 6 -characters 'ABCDEFGHKLMNPRSTUVWXYZ'
Randomize-Text $password
}
Get-ComplexPassword
Jul 14 2016