ou
This commit is contained in:
@@ -14,6 +14,33 @@ $csvPath = ".\users.csv"
|
|||||||
# Import from CSV
|
# Import from CSV
|
||||||
$users = Import-Csv -Path $csvPath
|
$users = Import-Csv -Path $csvPath
|
||||||
|
|
||||||
|
$base = "DC=company,DC=local"
|
||||||
|
|
||||||
|
$ous = @(
|
||||||
|
"OU=Employees,$base",
|
||||||
|
"OU=Directie,OU=Employees,$base",
|
||||||
|
"OU=HR,OU=Employees,$base",
|
||||||
|
"OU=BeheerOntwikkeling,OU=Employees,$base",
|
||||||
|
"OU=Duitsland,OU=Employees,$base",
|
||||||
|
"OU=Benelux,OU=Employees,$base",
|
||||||
|
"OU=ZuidEuropa,OU=Employees,$base",
|
||||||
|
"OU=SalesMarketing,OU=Employees,$base",
|
||||||
|
"OU=Operations,OU=Employees,$base",
|
||||||
|
"OU=FoodBeverages,OU=Employees,$base",
|
||||||
|
"OU=Hospitality,OU=Employees,$base",
|
||||||
|
"OU=ICT,OU=Employees,$base",
|
||||||
|
"OU=Finance,OU=Employees,$base"
|
||||||
|
)
|
||||||
|
|
||||||
|
foreach ($ou in $ous) {
|
||||||
|
if (-not (Get-ADOrganizationalUnit -LDAPFilter "(distinguishedName=$ou)" -ErrorAction SilentlyContinue)) {
|
||||||
|
New-ADOrganizationalUnit -Name ($ou.Split(",")[0].Replace("OU=","")) -Path ($ou.Substring($ou.IndexOf(",")+1))
|
||||||
|
Write-Host "Created OU: $ou"
|
||||||
|
} else {
|
||||||
|
Write-Host "OU already exists: $ou"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($user in $users) {
|
foreach ($user in $users) {
|
||||||
$FirstName = $user.FirstName
|
$FirstName = $user.FirstName
|
||||||
$LastName = $user.LastName
|
$LastName = $user.LastName
|
||||||
|
|||||||
Reference in New Issue
Block a user