-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbulk-user-addition.ps1
49 lines (40 loc) · 1.58 KB
/
bulk-user-addition.ps1
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
43
44
45
46
47
48
49
# ----- Edit these Variables for your own Use Case ----- #
$PASSWORD_FOR_USERS = "Password1"
$NUMBER_OF_ACCOUNTS_TO_CREATE = 10000
# ------------------------------------------------------ #
Function generate-random-name() {
$consonants = @('b','c','d','f','g','h','j','k','l','m','n','p','q','r','s','t','v','w','x','z')
$vowels = @('a','e','i','o','u','y')
$nameLength = Get-Random -Minimum 3 -Maximum 7
$count = 0
$name = ""
while ($count -lt $nameLength) {
if ($($count % 2) -eq 0) {
$name += $consonants[$(Get-Random -Minimum 0 -Maximum $($consonants.Count - 1))]
}
else {
$name += $vowels[$(Get-Random -Minimum 0 -Maximum $($vowels.Count - 1))]
}
$count++
}
$name
}
$count = 1
New-ADOrganizationalUnit -Name _USERS -ProtectedFromAccidentalDeletion $false
while ($count -lt $NUMBER_OF_ACCOUNTS_TO_CREATE) {
$firstname = generate-random-name
$lastName = generate-random-name
$username = $firstname + '.' + $lastName
$password = ConvertTo-SecureString $PASSWORD_FOR_USERS -AsPlainText -Force
Write-Host "[+] Creating Username:Password = $($username):'$($PASSWORD_FOR_USERS)'" -ForegroundColor Green
New-AdUser -AccountPassword $password `
-GivenName $first `
-Surname $last `
-DisplayName $username `
-Name $username `
-EmployeeID $username `
-PasswordNeverExpires $true `
-Path "ou=_USERS,$(([ADSI]`"").distinguishedName)" `
-Enabled $true
$count++
}