Updated 10th October 2024
It turns out that this post is very popular, so I thought I would revisit the processing of adding aliases to AD with PowerShell since quite a few things have changed in the 2 years since I wrote it.
You can also read this on Medium.com.

First of all: adding Active Directory aliases is a super simple task.
Manually Adding Active Directory Aliases
If you only have a single AD alias to add, then it’s often simpler and maybe even quicker to just use the Active Directory Users and Computers GUI. If you didn’t know, this is often abbreviated to ADUC. Quack, quack!
This control panel interface is often found on any of your domain controllers.
To add aliases manually, you would go through these steps:
- Open ADUC
- Find the user you need to add an alias to
- Right click the user and go to the Attributes tab
- In the long list, find proxyaddresses
- In this property, create a new record prefixed with smtp:
For example, you would need to enter:
smtp:first.last@example.com
If you entered the email without the smtp: prefix, then the entry wouldn’t have any effect.
That’s all well and good, but what if you need to add lots of aliases to lots of different people? Doing that manually would first be a pain, and also take a ton of time. Time that you don’t often have when working in IT.
This is where PowerShell can help us create these aliases automatically.
How to Upgrade MySQL Community to MySQL Enterprise on Red Hat 9
Been a while since I made a post, so let’s jump straight back in with…
How to Setup WordPress Backups (FREE!)
Personally, I like my website. A lot. And I wouldn’t want one mistake to make…
Install NGINX on an Offline RHEL System – 2 Systems Required!
Been a while since my previous post, but let’s hope the magic hasn’t rubbed off…
MySQL 8.4 Replication with SSL on Ubuntu 22.02
So I recently wrote a post and made a YouTube video on setting up MySQL…
Gutenberg Just Broke my Website
More of a story and vent than an informative article. So to save you reading…
How to Design a Website in 5 Steps
Adding Aliases to AD with PowerShell
First thing first, you’ll need to create a CSV or Comma Separated Values file. This is how PowerShell will determine which aliases to add to which Active Directory users or objects.
The formatting of the CSV file is very important, and the standardisation of data is what allows PowerShell to work so well.
The CSV will require 2 columns: 1 for the samaccountname of the user or object you want to add the alias to; and another for the proxy alias address that needs to be added.
ALL proxy addresses still need to be prefixed with smtp:
CSV Example #1
Say you had a user in Active Directory called John Smith. For this user, you wanted to add the following email addresses as aliases to his account: jsmith@example.com and john.smith@example.com. For this example, John Smith has a samaccountname of jsmith.
We would then format the CSV document like this ↓
| samaccountname | proxyaddresses |
| jsmith | smtp:jsmith@example.com;smtp:john.smith@example.com |
CSV Example #2
Now that I’ve shown you how to do this for a single user, let me show you an example with multiple users. We will still use the previous John Smith example, but now add his friends Lee Jones and Sam Ike. The CSV document would now look something like this:
| samaccountname | proxyaddresses |
| jsmith | smtp:jsmith@example.com;smtp:john.smith@example.com |
| ljones | smtp:ljones@example.com;smtp:lee.jones@example.com |
| sike | smtp:sike@example.com;smtp:sam.ike@example.com |
Now that the CSV file is built and ready, we can move onto the PowerShell script.
PowerShell Add Alias to AD
The PowerShell script needed is also fairly simple and can be broken down into the following steps:
- Import the CSV file
- Run through each item in the CSV and try to add the proxy addresses
- Output either a success or failure message
Below is the script that I use. You can see that I also wrap the Set-ADUser cmdlet in a try catch block. This should hopefully catch any errors and stop the script from exiting in an uncontrolled manor:
Import-Csv "path\to\csv" | ForEach-Object {
try{
Set-ADUser -Identity $_.samaccountname -add @{Proxyaddresses=$_.Proxyaddresses -split ";"} -ErrorAction Stop
Write-Host $_.samaccountname complete! -ForegroundColor Green
}catch{
Write-Host 'Failed : ' -NoNewline
Write-Host $_.samaccountname -ForegroundColor Red
}
}
Once you’ve built both components, you’ll need to update the CSV path in the PowerShell script.
You can now run the script for the aliases to be created.
Note: it can sometimes take between 30 seconds and 5 minutes for new aliases to show in Active Directory. This appears to depends on the size and scaling of the Active Directory environment and also the amount of aliases that have been added.
Comment below if you have any issues with this process!
Enjoy! 🎉
Just popping in to say thanks for posting this. Saved me a ton of time prepping for an email migration!
I am often searching for brand spanking new facts upon this kind of important
theme, and was especially stoked once I actually find websites that happen to be well-written and
well-researched. I want to thank you for providing this kind of wonderful data, and I take a look forward to learning much more out of
your blog in the long term future.
I am definitely seeking for new details on this kind of significant theme, and was specifically stoked when I locate blogs which might be well-written and well-researched.
I want to thank you for featuring this superb data, and I search
ahead to learning much more right from your blog
in the long term future.
We absolutely love your blog and find the majority of your post’s to be exactly I’m looking for.
Does one offer guest writers to write content available
for you? I wouldn’t mind publishing a post or elaborating on a lot of the subjects you write in relation to here.
Again, awesome web log!
Hi Savannah! Absolutely, I’m open to giving or receiving guest posts. Let me know if you’ like more information.
Hi there, I desire to subscribe for this webpage to get most up-to-date
updates, therefore where can i do it please assist.
Hey! There’s an email signup in the footer 😀
Hello there! Do you know if they make any plugins to help with
Search Engine Optimization? I’m trying to get my blog to rank for some targeted keywords but I’m not seeing very good results.
If you know of any please share. Kudos!
Check out Rank Math SEO 🙂
Hi mate, just wanted to say I really enjoyed this one… good stuff.
Love seeing people share useful content like this.
Anyway, I’m Andy from Australia, just trying to get my
name out there a bit more in the industry and get a bit of traction…
you know how it is. If you’re up for it, Id be stoked if you could help spread
the word a bit, but if not, all good!
Big cheers to anyone who does tho, really appreciate it either way!
Either way, keep doing what you do.
Cheers, Andrew from Kickstart Computers
Best of luck Brother!
Wow, superb blog layout! How long have you been blogging for?
you make blogging look easy. The overall look of your site is
excellent, as well as the content!