-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusers.ps1
More file actions
38 lines (32 loc) · 1.12 KB
/
Copy pathusers.ps1
File metadata and controls
38 lines (32 loc) · 1.12 KB
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
# we don't have scoring users!!!
# auto detect domain
$domain = (Get-ADDomain).DistinguishedName
$domainDNS = (Get-ADDomain).DNSRoot
# Define target OU
$targetOU = "CN=Users,$domain"
# bb
$password = ConvertTo-SecureString "bb123#123#123" -AsPlainText -Force
# users
$users = @("analyst1","analyst2","analyst3","analyst4","analyst5","analyst6","analyst7","analyst8")
Write-Host "Domain detected: $domainDNS" -ForegroundColor Cyan
Write-Host "Target OU: $targetOU" -ForegroundColor Cyan
Write-Host ""
# loop through users
foreach ($username in $users) {
try {
New-ADUser `
-Name $username `
-SamAccountName $username `
-UserPrincipalName "$username@$domainDNS" `
-Path $targetOU `
-AccountPassword $password `
-PasswordNeverExpires $true `
-Enabled $true `
-ErrorAction Stop
Write-Host "[+] Created user: $username" -ForegroundColor Green
}
catch {
Write-Host "[-] Failed to create user $username : $_" -ForegroundColor Red
}
}
Write-Host "Users created. Tell score to check scoring" -ForegroundColor Cyan