-
Notifications
You must be signed in to change notification settings - Fork 0
/
New-BulkRandomADUser
24 lines (21 loc) · 1.54 KB
/
New-BulkRandomADUser
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import-module activeDirectory
$firstnames = @("James" ,"John" ,"Robert" ,"Michael" ,"William" ,"Ronald" ,"Anthony" ,"Kevin" ,"Jason" ,"Jeff" ,"David" ,"Richard" ,"Charles" ,"Joseph" ,"Thomas" ,"George" ,"Kenneth" ,"Steven" ,"Edward" ,"Brian" ,"Christopher" ,"Daniel" ,"Paul" ,"Mark" ,"Donald")
$lastnames = @("Smith" ,"Johson" ,"William" ,"Jones" ,"Brown" ,"Davis" ,"Miller" ,"Wilson" ,"Moore" ,"Taylor" ,"Anderson" ,"Thomas" ,"Jackson" ,"White")
1..100 | ForEach-Object {
$firstname = $firstnames[$(Get-Random -Minimum 0 -Maximum $($firstnames.Length -1))]
$lastname = $lastnames[$(Get-Random -Minimum 0 -Maximum $($lastnames.Length -1))]
$firstname = $firstname.ToLower()
$lastname = $lastname.ToLower()
$firstletter = $firstname[0]
$user = "$firstname $lastname"
$Displayname = $user
$UserFirstname = $firstname
$UserLastname = $lastname
$OU = "CN=Users,DC=spiderweb,dc=local"
$SAM = "$firstletter$lastname"
$UPN = $firstname + "." + $lastname + "@" + "east.spiderweb.local"
$Description = "Domain User"
$Password = 'password'
New-ADUser -Name "$Displayname" -DisplayName "$Displayname" -SamAccountName $SAM -UserPrincipalName $UPN -GivenName "$UserFirstname" -Surname "$UserLastname" -Description "$Description" -AccountPassword (ConvertTo-SecureString $Password -AsPlainText -Force) -Enabled $true -Path "CN=Users,DC=east,DC=Spiderweb,DC=Local" -ChangePasswordAtLogon $false -PasswordNeverExpires $true
write-host "User $user created"
}