+ Post New Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 24
Internet Related/Filtering/Firewall Thread, Exchange 2010 - mail aliases / email addresses in Technical; Afternoon all, I'm setting up our new Exchange 2010 server, moving away from Desknow ( DeskNow - Mail and collaboration ...
  1. #1
    jonathanhaddock's Avatar
    Join Date
    Dec 2007
    Location
    Barton Court Grammar, Canterbury
    Posts
    58
    Thank Post
    0
    Thanked 6 Times in 4 Posts
    Rep Power
    15

    Post 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

  2. #2

    Join Date
    Sep 2006
    Location
    Essex
    Posts
    784
    Thank Post
    1
    Thanked 33 Times in 31 Posts
    Rep Power
    24
    You need to modify the Default Recipient Policy, the article linked below should help.

    Understanding E-Mail Address Policies: Exchange 2010 Help

  3. #3
    jonathanhaddock's Avatar
    Join Date
    Dec 2007
    Location
    Barton Court Grammar, Canterbury
    Posts
    58
    Thank Post
    0
    Thanked 6 Times in 4 Posts
    Rep Power
    15
    Thanks for the reply but unfortunately that's not the answer. This only allows you to base the email addresses on:
    %g - Given name (first name)

    %i - Middle initial

    %s -Surname (last name)

    %d - Display name

    %m - Exchange alias

    %xs - Uses the first x letters of the surname. For example, if x = 2, the first two letters of the surname are used.

    %xg - Uses the first x letters of the given name. For example, if x = 2, the first two letters of the given name are used.
    I think I'll need to learn PowerShell quickly in order to do this en masse and get this done, looks like exchange doesn't allow you to use username@ by default (which you'd think was an oversight).

  4. #4

    Join Date
    Sep 2006
    Location
    Essex
    Posts
    784
    Thank Post
    1
    Thanked 33 Times in 31 Posts
    Rep Power
    24
    Sorry hadn't realised you had already been down that road and I agree this does seem an oversight. So looks like PowerShell is your friend and to be honest I love PowerShell well worth getting to grips and IMO it makes Exchange 2007/2010 Management so much easier.

  5. #5
    jonathanhaddock's Avatar
    Join Date
    Dec 2007
    Location
    Barton Court Grammar, Canterbury
    Posts
    58
    Thank Post
    0
    Thanked 6 Times in 4 Posts
    Rep Power
    15
    No worries djm, just slightly depressed that although alias should automatically set to username that it doesn't seem to be. Do you know any good powershell tutorial sites?

    I'm thinking my script needs to:

    1) Connect to AD
    2) From the specified OU, run a for each against all user objects (CN=user) that:
    a) finds the upn prefix for the user
    b) runs the Enable-Mailbox command with -alias set to the upn prefix
    3) Report when complete

    Forunately, I have a test domain already for this - just going to be a pita learning power shell in a hurry!

    Jonathan

  6. #6

    Join Date
    Sep 2006
    Location
    Essex
    Posts
    784
    Thank Post
    1
    Thanked 33 Times in 31 Posts
    Rep Power
    24
    The article linked below is good start, Fortunately PowerShell as its name suggests is a powerful scripting tool and this should be fairly easy to do with one line of code.

    I will look though my old scripts, I may have one I wrote for E2K7 which I should work.

    Use the Set-MailUser cmdlet to modify the mail-related attributes of an existing user in Active Directory.

    Set-MailUser: Exchange 2010 Help

    Found this PowerShell which you my be able to adapt.
    This sets the mailusers' aliases from a CSV. The csv has two fields "name" and "alias" containing the name and the new alias.

    import-csv "c:\aliases\alias.csv"|foreach {set-mailuser -id $_.name -alias $_.alias -verbose -whatif}
    Last edited by djm968; 29th July 2010 at 03:37 PM.

  7. #7
    jonathanhaddock's Avatar
    Join Date
    Dec 2007
    Location
    Barton Court Grammar, Canterbury
    Posts
    58
    Thank Post
    0
    Thanked 6 Times in 4 Posts
    Rep Power
    15
    Hi Again,

    I'm in the process of writing a script which does what I outlined above, without using Set-MailUser.

    Running it up in a test environment first - if it works I'll provide a copy...

  8. #8
    jonathanhaddock's Avatar
    Join Date
    Dec 2007
    Location
    Barton Court Grammar, Canterbury
    Posts
    58
    Thank Post
    0
    Thanked 6 Times in 4 Posts
    Rep Power
    15

    Thumbs up 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!
    Attached Files Attached Files

  9. Thanks to jonathanhaddock from:

    rh91uk (3rd August 2010)

  10. #9
    rh91uk's Avatar
    Join Date
    Sep 2008
    Location
    UK
    Posts
    877
    Thank Post
    137
    Thanked 132 Times in 114 Posts
    Rep Power
    36
    That might be quick and dirty but it works for us! Thanks so much.

  11. #10

    Ric_'s Avatar
    Join Date
    Jun 2005
    Location
    London
    Posts
    7,592
    Thank Post
    109
    Thanked 770 Times in 598 Posts
    Rep Power
    183
    btw... a word of warning...

    I just used the script on an OU containing a dozen or so users and it has made a load of users vanish from AD (or as john put.... "committed murder"). Some of the missing users weren't even in the OU that I used the script on! Most random and most annoying!

  12. #11

    Ric_'s Avatar
    Join Date
    Jun 2005
    Location
    London
    Posts
    7,592
    Thank Post
    109
    Thanked 770 Times in 598 Posts
    Rep Power
    183
    It turns out that the script works perfectly if there are no mail-enabled or disabled users in the specified OU. Only then does it go a bit mental and start deleting people in other OUs!

    Oh well... it's given me a nice excuse to tidy up the usernames

  13. #12
    HMCTech's Avatar
    Join Date
    Apr 2008
    Posts
    618
    Thank Post
    37
    Thanked 48 Times in 35 Posts
    Rep Power
    23
    Would like to use this but a tad worried now about the previous two comments. We have a new year group in an OU to add mailboxes for and also half a dozen new pupils in all 6 other OU's all already full of users with mailboxes.

    Will this script work just by setting hte correct OU in $Dom = 'LDAP://OU=Dummy;OU=Students;OU=User;DC=bcgs;DC=local'

  14. #13
    jonathanhaddock's Avatar
    Join Date
    Dec 2007
    Location
    Barton Court Grammar, Canterbury
    Posts
    58
    Thank Post
    0
    Thanked 6 Times in 4 Posts
    Rep Power
    15
    The script shouldn't be able to delete anything - there's no delete line in the script anywhere! If it encounters an already email enabled user it errors saying it can't create one but I've not had any users deleted or vanish as a result.

    I've run the script on about 10 OUs in my domain and all was successful. If the script encounters a disabled user it won't create the mail box.

    @Ric_ - can you confirm the users are definitely gone?

    @AlexPilot
    That's what I was doing, targeting a single OU at a time...

    Jonathan
    (sorry for delayed response, was on holiday with no Internet)

  15. #14

    Ric_'s Avatar
    Join Date
    Jun 2005
    Location
    London
    Posts
    7,592
    Thank Post
    109
    Thanked 770 Times in 598 Posts
    Rep Power
    183
    Quote Originally Posted by jonathanhaddock View Post
    @Ric_ - can you confirm the users are definitely gone?
    They definitely went!

    I cannot work out what happened because I can see that the script should not effect anything but the alias and mail-enabled status... I can only think that it was something to do with either the disabled or mail-enabled accounts as those were the only things that errored. The users that went AWOL were even in different OUs! Random indeed!!!

    I have since run the script on 4 other OUs (approx. 450 users) and there hasn't been a problem (touch wood!).

  16. #15
    jonathanhaddock's Avatar
    Join Date
    Dec 2007
    Location
    Barton Court Grammar, Canterbury
    Posts
    58
    Thank Post
    0
    Thanked 6 Times in 4 Posts
    Rep Power
    15
    @Ric_
    Thanks for the clarification - you certainly had me worried that I'd done something wrong. I appreciate it doesn't help you but I'm happy to say it wasn't the script that did the deed.

    Was anything else happening in your domain at the time? What OS and domain/forest functionality level are you on?

    Jonathan



SHARE:
+ Post New Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Exchange 2010 not sending external mail
    By sfoord in forum Windows Server 2008
    Replies: 9
    Last Post: 21st August 2013, 03:53 PM
  2. exchange 2010 cant sent mail externally
    By RabbieBurns in forum Windows Server 2008 R2
    Replies: 10
    Last Post: 18th March 2013, 08:15 AM
  3. Web Mail to Exchange Email
    By IanT in forum Wireless Networks
    Replies: 6
    Last Post: 4th March 2010, 08:55 AM
  4. Replies: 3
    Last Post: 21st August 2009, 01:45 PM
  5. Replies: 8
    Last Post: 12th February 2009, 04:54 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •