Create Exchange Email Address Policy With Underscore


When onsite with a customer last week they were curious as to how they could create an Exchange Email Address Policy (EAP) with an underscore in it.  This was because the option to use an underscore is not present within the Exchange graphical tools. 

For the record, I’m personally not a fan of using special characters in any situation.  I’m a simple creature and do not use underscores or the ilk when defining email addresses.  For this example, we want to create the email addresses in the format of firstname_lastname@tailspintoys.ca

Since the option was not present in the graphical interface, time to break out PowerShell! 

In order to determine what PowerShell command to run, we can cheat (just a little) and use the wizard as a starting point.   Let’s run through the wizard and then tweak the output.  The below EAP will be targeted to a custom attribute.  Note that the focus of this post is to review the creation of the EAP itself, we can get into the application of that in a later post. 

 

Running Exchange 2010 Email Address Policy Wizard

At the organization level in the Exchange management tool, create a new Email Address Policy.  Specify the name and recipient types that are needed. 

Exchange Email Adddress Policy Wizard

In this case custom attribute 1 is used as a condition.  This is set to a non-existent  value since the Wizard us just helping us with the PowerShell command.  The EAP that we will use is going to be created in PowerShell later. 

Exchange Email Adddress Policy Wizard - Select Conditions

Then next we want to click add to chose the SMTP address format of the Email Address Policy. 

Exchange Email Adddress Policy Wizard - Add Email Addresses

Note that there is no option to chose an underscore in the below screenshot.  The default selection is to use the alias. 

Exchange Email Adddress Policy Wizard - Add Email Address Local Parts

Since we want to create the email addresses in the format of firstname_lastname@tailspintoys.ca, lets chose the closest option that matches. 

Exchange Email Adddress Policy Wizard - Add Email Address Local Parts Select First Last

Clicking next produces the typical %g.$s@tailspintoys.ca . 

Exchange Email Adddress Policy Wizard - Add Email Address Local Parts Selected First Last

In this example we are not applying the Email Address Policy.  This is just being used to discover the underlying PowerShell. 

Exchange Email Adddress Policy Wizard - Add Email Address Apply Later

Clicking next, will create the policy. 

Exchange Email Adddress Policy Wizard - Created Email Address Policy

In the Final screen we can copy out the PowerShell command used. 

Exchange Email Adddress Policy Wizard - Email Address Policy Wizard Complete

The copied command is shown below:

 

Summary: 1 item(s). 1 succeeded, 0 failed.
Elapsed time: 00:00:11

New Address Policy 01
Completed

Exchange Management Shell command completed:
new-EmailAddressPolicy -Name 'Address Policy 01' -IncludedRecipients 'AllRecipients' -ConditionalCustomAttribute1 'Corp' -Priority '1' -EnabledEmailAddressTemplates 'SMTP:%g.%s@Tailspintoys.ca'

Elapsed Time: 00:00:11

 

Standing On The Shoulders Of Giants

Now that we have the basic syntax, all we have to do is to modify the name and format of the policy.  Note that in the below example, the name and format of the Email Address was changed – the underscore was inserted. 

New-EmailAddressPolicy -Name 'Underscore Policy' -IncludedRecipients 'AllRecipients' -ConditionalCustomAttribute1 'Corp' -Priority '1' -EnabledEmailAddressTemplates 'SMTP:%g_%s@Tailspintoys.ca'

Looks good, so time to execute in PowerShell:

Creating Email Address Policy In PowerShell

The EAP was successfully created.

 

Reviewing Underscore EAP In Exchange Management Console

If we then review the new EAP in the graphical tool, we can see that the address format is correct. 

Reviewing Underscore Email Address Policy

However, if we try to edit the email address, there is no option as this is not recognised by the graphical interface. 

Unable To Edit Underscore Email Address Policy Details

If we need to make modifications to the format of the EAP, then it’s back to PowerShell we go!

Cheers,

Rhoderick

Comments (0)

Skip to main content