返回列表 发帖

[转载代码] [PowerShell每日技巧]创建随机密码(20131211)

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"COPY
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.

http://powershell.com/cs/blogs/tips/archive/2013/12/11/creating-temporary-password.aspx
1

评分人数

    • CrLf: [Char[]]技术 + 1

返回列表