AD Mass Department+Division+Description And More Changer

#fromOU
# OU'nun DistinguishedName'ini belirleyin
$ouDistinguishedName = "OU=test,DC=guler,DC=com"
# Yeni değerleri belirtin
$newDepartment = "YeniDepartman"
$newDivision = "YeniBölüm"
$newDescription = "YeniAçıklama"
# Belirtilen OU altındaki kullanıcıların tüm alanlarını güncelleyin
Get-ADUser -Filter * -SearchBase $ouDistinguishedName | ForEach-Object {
Set-ADUser -Identity $_ -Replace @{
Department = $newDepartment
Division = $newDivision
Description = $newDescription
}
}#from CSV FILE
# CSV dosyasının yolunu belirtin:
$csvFilePath = "C:\files\degistir.csv"
# Yeni değerler:
$newDepartment = "YeniDepartman"
$newDescription = "YeniAçıklama"
# CSV dosyasını içe aktar:
$userData = Import-Csv -Path $csvFilePath
# Her bir kullanıcı için güncelle:
foreach ($user in $userData) {
$sAMAccountName = $user.sAMAccountName
# Kullanıcıyı sAMAccountName'e göre bulun:
$userToUpdate = Get-ADUser -Filter {sAMAccountName -eq $sAMAccountName}
if ($userToUpdate) {
# Kullanıcının özelliklerini güncelleyin
Set-ADUser -Identity $userToUpdate -Replace @{
Department = $newDepartment
Description = $newDescription
}
Write-Host "Kullanıcı $sAMAccountName güncellendi."
} else {
Write-Host "Kullanıcı $sAMAccountName bulunamadı."
}
} This post is licensed under CC BY 4.0 by the author.