Téléverser les fichiers vers "/"

This commit is contained in:
2026-01-27 09:27:44 +00:00
commit 65b7d5461b
5 changed files with 347 additions and 0 deletions

23
insert_OUs.ps1 Normal file
View 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
}
}