Adding Aliases to AD with PowerShell

Mark Harwood
2 min readJun 15, 2022

Adding aliases in AD is a VERY simple task.

You can just find the user via the ADUC (Active Directory Users and Computers), go to the ‘ attributes’ tab on them, find ‘ proxyaddresses’ and add a new record prefixed with smtp:. For example, you could add ‘ smtp:firstname.lastname@domain.com

But what if you need to add lots of aliases to lots of people?

You can do this with just a CSV file and the right PowerShell commands.

First, lets start off with the formatting of the CSV file. This should have two columns, one for the samaccountname of the user and another for the proxy addresses. Proxy addresses NEED to be prefixed with ‘ smtp: ‘, separated by a semi-colon and all lowercase.

Here’s an example:

+ — — — — — — — — + — — — — — — — — — — — +
| samaccountname | Proxyaddress |
+ — — — — — — — — + — — — — — — — — — — — +
| username | smtp:name@domain.com |
+ — — — — — — — — + — — — — — — — — — — — +

Next, we need to build the correct PowerShell script. I’ll list the steps of the script below followed by the script itself:

  1. Import the CSV file
  2. Run through each item in the CSV and try to add the proxy addresses
  3. Output either a success or failure message
Import-Csv "path\to\csv" | ForEach-Object{…

--

--

Mark Harwood

IT Pro 👨‍💻 Dad 👀 Husband🔒 Check out my free blog or utilise my expertise on the web! https://mharwood.uk