Hey everyone! I manage a hybrid 365 environment and I'm needing to add secondary email aliases for all users in a specific Organizational Unit. The primary email format is [email protected], and I want the aliases to be in the format [email protected].
I've been using PowerShell to add aliases for individual users by modifying their proxy addresses, and it works great for my own account. Here's a snippet of the script I tested:
```powershell
Import-Module ActiveDirectory
$OU = "OU=Test OU,DC=company,DC=companyname,DC=com"
$users = Get-ADUser -Filter * -SearchBase $OU -Properties proxyAddresses, GivenName, Surname
foreach ($user in $users) {
if ($user.GivenName -and $user.Surname) {
$alias = "smtp:{0}.{1}@companyname.com" -f $user.Surname.ToLower(), $user.GivenName.ToLower()
if ($user.proxyAddresses -notcontains $alias) {
Set-ADUser $user -Add @{proxyAddresses = $alias}
Write-Host "Added alias $alias to user $($user.SamAccountName)"
} else {
Write-Host "Alias $alias already exists for $($user.SamAccountName)"
}
} else {
Write-Warning "Skipping $($user.SamAccountName): missing GivenName or Surname"
}
}
```
Does anyone have thoughts on the best approach for bulk adding these aliases?
3 Answers
If you're using Exchange On-Premise, modifying the email address policy could be a smoother way to handle this. It might not work exactly the same in a hybrid setup, but it could save you some manual work in the long run. If you were to add a secondary email to the existing policy, it should update already existing accounts, not just new ones. That's definitely worth considering!
You've got to think about uniqueness as well. If you end up having employees with the same or similar names, like Jack Paul and Paul Jack, that could cause some issues down the line. You might want to establish some rules for resolving such conflicts if they arise in the future.
Just keep in mind that some users might have spaces or special characters in their names. It could be safer to modify their existing email rather than trying to create new aliases, especially if you're concerned about potential conflicts with names.

Thanks for the tip! I hadn’t thought about the policy. If it updates existing accounts, that would be a great way to avoid the manual process for new users.