Created
October 5, 2022 09:06
-
-
Save w0ltage/f16144123cf3bc5e8aa5dd881113ba47 to your computer and use it in GitHub Desktop.
Powershell - Create N random users
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Creates 20 random users with password "username_first_letter-Ww12345" | |
# For user "G7sk9Ilo" password will be "G-Ww12345" | |
for ($user_num = 1; $user_num -le 20; $user_num++){ | |
$ruser = -join ((48..57) +(65..90) + (97..122) | Get-Random -Count 8 | % {[char]$_}) | |
$rpassword = ConvertTo-SecureString "$($ruser.Substring(0,1))-Ww12345" -AsPlainText -Force | |
$null = New-LocalUser $ruser -Password $rpassword -FullName $ruser -Description "password almost same as name" | |
Write-Host "`r`nUSERNAME: $($ruser) `r`nNUMBER: $($user_num)" | |
} | |
Get-LocalUser |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment