-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPasswordGenerator.ps1
More file actions
42 lines (30 loc) · 1.28 KB
/
PasswordGenerator.ps1
File metadata and controls
42 lines (30 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
$Host.UI.RawUI.WindowTitle = "Password Generator - Emmanuel MARCEROU"
function Generate-RandomPassword {
param (
[int]$length
)
$upperCase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
$lowerCase = "abcdefghijklmnopqrstuvwxyz"
$numbers = "0123456789"
$symbols = "!@#$%&*()-_=+.?/"
$allChars = $upperCase + $lowerCase + $numbers + $symbols
$password = (Get-Random -InputObject $upperCase -Count 1) +
(Get-Random -InputObject $lowerCase -Count 1) +
(Get-Random -InputObject $numbers -Count 1) +
(Get-Random -InputObject $symbols -Count 1)
while ($password.Length -lt $length) {
$password += Get-Random -InputObject $allChars -Count 1
}
$passwordArray = $password.ToCharArray() | Sort-Object {Get-Random}
return -join $passwordArray[0..($length-1)]
}
[int]$numberOfPasswords = Read-Host "Entrez le nombre de mots de passe à générer"
[int]$passwordLength = Read-Host "Entrez la longueur des mots de passe à générer"
Write-Host ""
for ($i = 1; $i -le $numberOfPasswords; $i++) {
$password = Generate-RandomPassword -length $passwordLength
Write-Host "Mot de passe $i : $password"
}
Write-Host ""
Write-Host "Appuyez sur une touche pour quitter..."
[System.Console]::ReadKey($true)