PI Services

Le blog des collaborateurs de PI Services

Powershell : Générateur de mot de passe

Vous en avez marre de chercher un nouveau mot de passe, ou vous devez générer des mots de passe pour u grand nombre d'utilisateur ?

Voici quelques lignes Powershell que vous pouvez utiliser dans une fonction ou  dans une boucle pour générer un mot de passe.

$TinyCharacters = "a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"
$CapitalCharacters = "A",",B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"
$NumeralCharacters = "0","1","2","3","4","5","6","7","8","9"
$SpecialCharacters = "!","$","%","&","/","(",")","=","?","}","]","[","{","@","#","*","+"
$Password = $null

1..3 | ForEach-Object {
    $Password += Get-Random -Minimum 1 $TinyCharacters
    $Password += Get-Random -Minimum 1 $CapitalCharacters
    $Password += Get-Random -Minimum 1 $NumeralCharacters
    $Password += Get-Random -Minimum 1 $SpecialCharacters
    }
$Password

Ces quelques ligne vous permettront de générer un mot de passe de 12 caractères, pour un mot de passe plus long changez la valeur de 1..3 à 1..4 ou 1..5

Ajouter un commentaire

Loading