Téléverser les fichiers vers "/"
This commit is contained in:
23
insert_OUs.ps1
Normal file
23
insert_OUs.ps1
Normal file
@@ -0,0 +1,23 @@
|
||||
# Nom du script : insert_OUs.ps1
|
||||
Import-Module ActiveDirectory
|
||||
|
||||
$csvPath = "happy_koalas_employees.csv"
|
||||
$domainDN = (Get-ADDomain).DistinguishedName
|
||||
|
||||
Write-Host "--- Cr<43>ation des Unit<69>s d'Organisation (OU) ---" -ForegroundColor Cyan
|
||||
|
||||
# Lecture du CSV
|
||||
$employees = Import-Csv -Path $csvPath -Delimiter ";"
|
||||
|
||||
# On r<>cup<75>re la liste unique des d<>partements
|
||||
$departments = $employees | Select-Object -ExpandProperty Department -Unique
|
||||
|
||||
foreach ($dept in $departments) {
|
||||
# On v<>rifie si l'OU existe d<>j<EFBFBD> pour <20>viter les erreurs rouges
|
||||
if (-not (Get-ADOrganizationalUnit -Filter "Name -eq '$dept'")) {
|
||||
New-ADOrganizationalUnit -Name $dept -Path $domainDN
|
||||
Write-Host "[OK] OU cr<63><72>e : $dept" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "[INFO] L'OU $dept existe d<>j<EFBFBD>." -ForegroundColor Yellow
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user