Powershell ile Rastgele(Random) Parola(Password) Üretme – Fonksiyon

Function GeneratePassword {
param([int]$length) 
    IF($length -lt 6) {Write-Host " Minimum 6 karakterli olusturabilir";Break}
    $kalan=$length - 5
    
    $charsetLower="abcdefghkmnprstuvyz".ToCharArray() | Get-Random -Count $kalan | % {[char]$_}
    $charsetUpperr="ABCDEGFGHLMNPRSTVYZ".ToCharArray() | Get-Random -Count 2 | % {[char]$_}
    $alphaset=".*!".ToCharArray() | Get-Random
    $sayi = 10..99 | Get-Random
    $pass=-join($charsetUpperr + $charsetLower + $alphaset + $sayi)
    return $pass
 }

Script çağırma işlemi için;

$randomPass = GeneratePassword -length 12

GeneratePassword -length 12