Powershell – Bulk Update Active Directory Department Field
Bulk update the Department field in active directory using Powershell Get-ADUser and Set-ADUser cmdlets.
# define the OU you want to set $ou = "OU=Oregon,OU=Sales,OU=Users,DC=contoso,DC=com" # define the server you want to make the changes on $domainController = "dc1.constoso.com" # set department text $departmentText = 'Oregon - Sales' # get the list of users $users = Get-ADUser -Server $domainController -SearchBase $ou -Filter {(ObjectClass -eq "user")} -Properties Department # apply the new department to the users we found ForEach ($u in $users) { $u | Set-ADUser -Department $departmentText -Server $domainController }