Here's a chunk of code that creates random passwords of different lengths for you:
$length = 8 $characters = [Char[]]((31..50) + (65..90) + (97..122)) $characters = $characters -ne 'O' -ne 'o' -ne 'l' -ne '1' -ne '-' $password = -join ($characters | Get-Random -Count $length) "Your temporary $length-character-password is $password"
The password length is set by $length. The characters used to compose the passwords are defined in $characters. By default, all ASCII codes from 31-50, 65-90, and 97-122 are used. As you can see, with the -ne operator, you can fine-tune the list and exclude characters. In our example, we exclude characters that can easily be misinterpreted.