Updating Active Directory User Attribute for 365 Address Lists
This script grabs all users in a specific OU, then updates their extensionAttribute10 to whatever value you want—like the name of the address list they should belong to. Just point it at your OU, set the value, and run. Each user gets updated, and you get a confirmation message for every change.
It’s a simple way to bulk-assign users to the correct address lists without clicking through each AD user one by one. Saves time and keeps your GAL organized!
# Import Active Directory module
Import-Module ActiveDirectory
# Define the value to be added and the attribute name
$attributeValue = "Address List Name"
$attributeName = "extensionAttribute10"
# Specify the OU (Organizational Unit) - replace with your OU's distinguished name
$ouDistinguishedName = "OU=*****,OU=*****Users,OU=******,OU=*****, DC=*****,DC=*****,DC=**,DC=**"
# Get all users in the specified OU
$usersInOU = Get-ADUser -Filter * -SearchBase $ouDistinguishedName
# Loop through each user and update the attribute
foreach ($user in $usersInOU) {
Set-ADObject -Identity $user -Add @{ $attributeName = $attributeValue }
Write-Host "Attribute $attributeName updated for $($user.SamAccountName)"
}
# Output a final confirmation message
Write-Host "All users in $ouDistinguishedName have been updated."