-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreate_ADuser.ps1
More file actions
32 lines (27 loc) · 892 Bytes
/
Create_ADuser.ps1
File metadata and controls
32 lines (27 loc) · 892 Bytes
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
# Basic Script to create AD Users massively
# 2022 Marci Arévalo
# Import AD Module
Import-Module ActiveDirectory
# Path and file name origin
$directorio_origen = $PSScriptRoot
$archivo_origen = $directorio_origen+"\users.csv"
# Info in console: the script starts
write-host Creando usuarios... -ForegroundColor Yellow
# Import csv file and start the loop
Import-Csv $archivo_origen | ForEach-Object {
$upn = $_.SamAccountName + “@tudominio.es”
$uname = $_.FirstName
$descript = "Description"
New-ADUser -Name $uname `
-DisplayName $uname `
-GivenName $_.FirstName `
-UserPrincipalName $upn `
-SamAccountName $_.samAccountName `
-Enabled $true `
-Description $descript `
-Path $_.OU `
-AccountPassword (ConvertTo-SecureString $_.Password -AsPlainText -force)
write-host $uname Creado
}
#Info in console: the script has finished
write-host Usuarios Creados!!! -ForegroundColor Green