none
Name changes with On-Premise Exchange Server 2010 and Office 365 RRS feed

  • Question

  • We are encountering an issue when a student changes their name.  We are not sure when this issue started but were looking for some insight as to how to resolve the issue.  We have an On-Premise Exchange Server 2010 for staff and Office 365 for students. 

    Summary: When a name change is completed via the Exchange Management Shell (EMS) Set-MailUser command the original Office 365 PrimarySMTPAddress/ExternalEmailAddress is removed rather than retained as an alias smtp email address.

    Detail:

    Within our On-Premise implementation we have MailUsers defined for our Office 365 students similar to the following:

    Name                      : smiley1234

    Alias                     : smiley1234

    PrimarySmtpAddress        : smiley1234@my.school.edu

    EmailAddresses            : {smtp:smiley1234@school.edu, SMTP:smiley1234@my.school.edu}

    ExternalEmailAddress      : SMTP:smiley1234@my.school.edu

    EmailAddressPolicyEnabled : True

    We change their alias and external email address via the following EMS command (note this is done after changing their name in AD):

    set-mailuser -identity 55551234@school.edu -domaincontroller DOMCTRLR.college.school.tech -externalemailaddress grey1234@my.school.edu -alias grey1234

    We have discovered the original PrimarySMTPAddress/ExternalEmailAddress is not being retained as an alias.  See the following output after the set-mailuser command has run:

    Name                      : grey1234

    Alias                     : grey1234

    PrimarySmtpAddress        : grey1234@my.school.edu

    EmailAddresses            : {smtp:grey1234@school.edu, SMTP:grey1234@my.school.edu, smtp:smiley1234@school.edu}

    ExternalEmailAddress      : SMTP:grey1234@my.school.edu

    EmailAddressPolicyEnabled : True

    Note that smiley1234@my.school.edu has been removed and not retained as an Email Address alias.  This results in the student not getting mail via their old email address. This is contrary to the staff command behavior for our on premise accounts where the original PrimarySMTPAddress is retained as an alias.

    Do you have any recommendations how to resolve this issue? 

    Tuesday, September 17, 2013 8:55 PM

All replies

  • First of all is this the correct forum for Exchange Management Shell questions?  If not, can you recommend where I should post this?

    ## ORIGINAL COMMAND

    Set-MailUser -identity 12345678@school.edu -domaincontroller DOMCTRLR.college.school.tech -ExternalEmailAddress sunshine5678@my.school.edu –Alias sunshine5678


    ## Resulted in the original Office365 email address being removed; e.g.,If grey5678@my.school.edu was the original SMTP/External (Office365 account) email address it was removed from the On-Premise email address list. The On-Premise email address remained: grey5678@school.edu.  WHY is the email address removed?  This is a different behaviour than the Set-Mailbox command where the original address is retained.

    ## NEW STUDENT NAME CHANGE:

    ## ALTERNATIVE #1
     Set-MailUser -identity 12345678@school.edu -domaincontroller DOMCTRLR.college.school.tech –PrimarySmtpAddress sunshine5678@my.school.edu -ExternalEmailAddress sunshine5678@my.school.edu –Alias sunshine5678 –EmailAddressPolicyEnabled $false
     
    ## The above command could be broken into two commands
     Set-MailUser -identity 12345678@school.edu -domaincontroller DOMCTRLR.college.school.tech –PrimarySmtpAddress sunshine5678@my.school.edu –Alias sunshine5678 –EmailAddressPolicyEnabled $false
     Set-MailUser -identity 12345678@school.edu -domaincontroller DOMCTRLR.college.school.tech -ExternalEmailAddress sunshine5678@my.school.edu 
    
    ## For both the single or double commands above the EmailAddressPolicyEnabled must be turned back on
     Set-MailUser -identity 12345678@school.edu -domaincontroller DOMCTRLR.college.school.tech –EmailAddressPolicyEnabled $true
     


    The above logic works well in a Powershell command prompt but not from a VB.Net program similar to the following:

    ps.Streams.ClearStreams()
     ps.Commands.Clear()
     ps.AddScript("set-mailuser -identity " & upnBeingProcessed & " -domaincontroller " & dnsHostFQDName & " –primarysmtpaddress " & newStudentMail & " –alias " & studentCommonName & " –emailaddresspolicyenabled 0")
     ps.AddScript("set-mailuser -identity " & upnBeingProcessed & " -domaincontroller " & dnsHostFQDName & " -externalemailaddress " & newStudentMail)
     ps.AddScript("set-mailuser -identity " & upnBeingProcessed & " -domaincontroller " & dnsHostFQDName & " –emailaddresspolicyenabled 1")
     ps.AddScript("Update-GlobalAddressList -Identity 'Default Global Address List'")
     ps.AddScript("start-sleep -s 200")
     ps.AddScript("get-mailuser -identity " & upnBeingProcessed & " -domaincontroller " & dnsHostFQDName & " | fl primarysmtpaddress ")
     ps.AddCommand("Out-String")
     
    Dim commandResults As Collection(Of PSObject) = Nothing
     commandResults = ps.Invoke()
    


    ## When this script runs it goes on a walk-about, not to return until about 4 minutes later, for each account!  It does not time out but I do watching it.

    ## ALTERNATIVE #2 without turning off the emailaddresspolicyenabled switch to make the change.
     
    $mu=get-mailuser -identity 12345678@school.edu -domaincontroller DOMCTRLR.college.school.tech
     $psmtpaddr = $mu.emailaddresses|?{$_.IsPrimaryAddress -and $_.PrefixString -eq "SMTP"}
     Set-MailUser -identity 12345678@school.edu -domaincontroller DOMCTRLR.college.school.tech -ExternalEmailAddress sunshine5678@my.school.edu –Alias sunshine5678 -EmailAddresses @{'+'=$psmtpaddr.smtpAddress}
     Get-MailUser -identity 12345678@school.edu -domaincontroller DOMCTRLR.college.school.tech | fl name, alias, primarysmtpaddress, emailaddresses, externalemailaddress, emailaddresspolicyenabled
    

    Alternative 2 works well in a EMS command prompt but I'm not sure how it will run in our VB.Net program.  Is there any reason to not use either alternative and/or do you have a better alternative?

    Thanks in advance for your assistance,

    Steve

    • Edited by seiden Wednesday, October 2, 2013 5:55 PM insert script blocks
    Wednesday, October 2, 2013 5:49 PM