Description:
1. A total of 8 passwords.
2. It consists of 2 numbers, 2 uppercase characters, 2 lower-case characters, and 2 special characters.
3. The character order is random.
Copy codeThe Code is as follows: function CreatePassword
{
$ Figure = 1, 2, 4, 5, 6, 7, 8, 9;
$ Capital = "Q", "W", "E", "R", "T", "Y", "U", "I", "O ", "P", "A", "S", "D", "F", "G", "H", "J", "K", "L ", "Z", "X", "C", "V", "B", "N", "M ";
$ Lowercase = "q", "w", "e", "r", "t", "y", "u", "I", "o ", "p", "a", "s", "d", "f", "g", "h", "j", "k", "l ", "z", "x", "c", "v", "B", "n", "m ";
$ SpecialCharacter = "~ ","! "," @ "," # "," $ "," % "," ^ ","&","*","(",")", "-", "+ ";
$ Order = New-Object System. Collections. ArrayList;
For ($ I = 0; $ I-lt 8; $ I ++)
{
[Void] $ order. Add ($ I );
}
$ NewOrder = @();
For ($ I = 0; $ I-lt 8; $ I ++)
{
$ ProduceOrder = Get-Random-InputObject $ order;
$ NewOrder + = $ produceOrder;
$ Order. Remove ($ produceOrder );
}
$ NewPassword = @();
Foreach ($ I in $ newOrder)
{
If ($ I-eq 0)
{
$ Index = Get-Random-Maximum 8;
$ NewPassword + = $ figure [$ index];
}
If ($ I-eq 1)
{
$ Index = Get-Random-Maximum 8;
$ NewPassword + = $ figure [$ index];
}
If ($ I-eq 2)
{
$ Index = Get-Random-Maximum 25;
$ NewPassword + = $ capital [$ index];
}
If ($ I-eq 3)
{
$ Index = Get-Random-Maximum 25;
$ NewPassword + = $ capital [$ index];
}
If ($ I-eq 4)
{
$ Index = Get-Random-Maximum 25;
$ NewPassword + = $ lowercase [$ index];
}
If ($ I-eq 5)
{
$ Index = Get-Random-Maximum 25;
$ NewPassword + = $ lowercase [$ index];
}
If ($ I-eq 6)
{
$ Index = Get-Random-Maximum 12;
$ NewPassword + = $ specialCharacter [$ index];
}
If ($ I-eq 7)
{
$ Index = Get-Random-Maximum 12;
$ NewPassword + = $ specialCharacter [$ index];
}
}
Return $ newPassword-join "";
}
Test Results: