Exchange 2010 - mail aliases / email addresses
Afternoon all,
I'm setting up our new Exchange 2010 server, moving away from Desknow (DeskNow - Mail and collaboration server, hardly anyone's ever heard of it, falls into the "poor" bracket, not my choice gladly). What I'm stumbling on is the email addresses.
My internal domain is of the form bcgs.local, externally that's bartoncourt.org - no problem, I've created an email address policy and set up the accepted domains that covers that. The problem is, the email address the email policy sets up isn't the same as the present email address users expect:
* previously, email addresses were of the form username@bartoncourt.org
* the email address policy, set to "alias@accepteddomain" (so "alias@bartoncourt.org") isn't the same - although alias should equal the username ("By default, this field is populated based on the User logon name (User Principal Name) of the user." (How to Create a Mailbox for a New User: Exchange 2007 Help)
).
So, does anyone know how to fix this frustraing problem? Otherwise I'll end up setting up each account individually just so I can specify the email address (alias) correctly.
Thanks in advance,
Jony
1 Attachment(s)
The fix - one quick and dirty powershell script
Ok, at the risk of sounding presumptuous I'm going to mark this post as the answer. I had to write a powershell script to do this. Naturally I ran it up in a test environment first.
Attached is a txt with the script which is also below:
Code:
# PowerShell find UPN of users in the given OU and create Exchange Mailbox with the alias == UPN
# If the mailbox already exists, the script errors on that entry.
# Author: Jonathan Haddock, following an example PS foreach script from Guy Thomas
# (PowerShell - Active Directory LDAP DirectoryServices.DirectoryEntry)
# Version 1, August 2010, tested with WinSvr 2008 R2 Stnd and Exchange 2010 Stnd
$Dom = 'LDAP://OU=Dummy;OU=Students;OU=User;DC=bcgs;DC=local'
$Root = New-Object DirectoryServices.DirectoryEntry $Dom
$i=0
# Create a selector and start searching from the Root of AD
$selector = New-Object DirectoryServices.DirectorySearcher
$selector.SearchRoot = $root
$adobj= $selector.findall() |`
where {$_.properties.objectcategory -match "CN=Person"}
foreach ($person in $adobj){
$prop=$person.properties
$i++
# In AD the property is userPrincipalName however, PS makes the attribute lower case, hence userprincipalname
$upn = $prop.userprincipalname[0]
# The UPN contains @ followed by the suffix, we only want the UPN prefix so we use split:
$upnsplit = $upn.split("@")
$alias = $upnsplit[0]
# Output the alias to the screen:
Write-host $alias
# Enable the exchange mailbox
Enable-Mailbox -Identity "$upn" -Alias "$alias"
}
"Total $i"
Please note: I take no responsibility for what this script may do to your Exchange 2010 system. I have tested the script and it works fine in my environment but there is no guarantee it will work the same in yours.
Thanks for everyone else's help on this!