-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbulk-user-from-names.ps1
29 lines (22 loc) · 1.01 KB
/
bulk-user-from-names.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
# ----- Edit these Variables for your own Use Case ----- #
$PASSWORD_FOR_USERS = "Password1"
$USER_FIRST_LAST_LIST = Get-Content .\names.txt
# ------------------------------------------------------ #
$count = 1
New-ADOrganizationalUnit -Name _USERS -ProtectedFromAccidentalDeletion $false
foreach ($n in $USER_FIRST_LAST_LIST) {
$firstname = $n.Split(" ")[0].ToLower()
$lastName = $n.Split(" ")[1].ToLower()
$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
}