Arroyo.Password.psm1
function Get-RandomCharacters { param ( $Length, $Characters ) $Random = 1..$Length | ForEach-Object { Get-Random -Maximum $Characters.length } $Private:ofs = "" return [string]$Characters[$Random] } function ScrambleString { param ( [string]$InputString ) $CharacterArray = $InputString.ToCharArray() $ScrambledStringArray = $CharacterArray | Get-Random -Count $CharacterArray.Length $OutputString = -Join $ScrambledStringArray return $OutputString } function Get-Password { $Password = Get-RandomCharacters -Length 8 -Characters 'abcdefghiklmnoprstuvwxyz' $Password += Get-RandomCharacters -Length 4 -Characters 'ABCDEFGHKLMNOPRSTUVWXYZ' $Password += Get-RandomCharacters -Length 2 -Characters '1234567890' $Password += Get-RandomCharacters -Length 2 -Characters '!%/=?@#*+' Return ScrambleString -InputString $Password } |