none
How could I specify proxyaddresses and legacyExchangeDN when we create new mailbox in Exchange2010 by cmdlet ?

    Question

  • How could I specify proxyaddresses and legacyExchangeDN when we create new mailbox in Exchange2010 by cmdlet ?
    Friday, July 12, 2013 9:24 AM

Answers

  • I can't test from where I am how you might mod this to add the legacyExchangeDN, and I only know that it works on Exchange 2007, but this might help. Script below updates existing mailboxes from a csv list containing the user alias and the required legacyExchangeDN (x500) address to be added to it. You could either use it as is to update the accounts afterwards, or use some of it to adjust your existing creation script.

    # Expected format of the csv is :
    # <alias>,X500:<x500 address>
    # so you have to ensure you've edited the csv to match and end up with for instance :
    # Bob,X500:/o=MYOLDDOMAIN/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Recipients/cn=bob
    
    $adminsessionadsettings.viewentireforest = $true
    
    import-csv c:\batchscripts\x500\x500list.csv -Header Alias,x500 | foreach-object{
        write-host "alias for " $_.Alias " is " $_.x500
        $currentmailbox = Get-Mailbox -domaincontroller "mydc.co.uk" -identity $_.Alias
        $currentmailbox.EMailAddresses.Add($_.x500)
        Set-Mailbox -instance $currentmailbox
    }
    Hope that helps.


    Saturday, July 13, 2013 7:09 PM

All replies

  • For the e-mail addresses use New-Mailbox with the -EmailAddresses parameter.  You can set the -Alias parameter, which goes into the legacyExchangeDN, but beyong that I don't know how to change the legacyExchangeDN without using ADSI.  Why would you want to?  I've never had a need to change that property, and I'd be afraid of breaking internal things in Exchange.

    Ed Crowley MVP "There are seldom good technological solutions to behavioral problems."


    • Edited by Ed CrowleyMVP Saturday, July 13, 2013 1:43 AM Correction
    Saturday, July 13, 2013 1:41 AM
  • Thank you.

    I am trying to make test Exchange environment.

    I would like to export mailboxes information from production Exchange environment

    and make same mailboxes to test  Exchange environment.

    That is because I would like to specify the legacyExchangeDN value when creating new mailboxes.

    Saturday, July 13, 2013 6:22 PM
  • Use ADSI to do it. Here's an example that changes the LDN from it's original value to "NewFoo":

    $dn=(get-mailbox foo).distinguishedname
    $m=[ADSI]"LDAP://$dn"
    $ldn=$m.properties.legacyexchangedn[0]
    $ldn
    $m.properties.legacyexchangedn[0] = "/o=<ORG>/ou=First Administrative Group/cn=Recipients/cn=NewFoo"
    $m.SetInfo()
    $ldn=$m.properties.legacyexchangedn[0]
    $ldn


    --- Rich Matheisen MCSE&I, Exchange MVP

    Saturday, July 13, 2013 6:53 PM
  • I can't test from where I am how you might mod this to add the legacyExchangeDN, and I only know that it works on Exchange 2007, but this might help. Script below updates existing mailboxes from a csv list containing the user alias and the required legacyExchangeDN (x500) address to be added to it. You could either use it as is to update the accounts afterwards, or use some of it to adjust your existing creation script.

    # Expected format of the csv is :
    # <alias>,X500:<x500 address>
    # so you have to ensure you've edited the csv to match and end up with for instance :
    # Bob,X500:/o=MYOLDDOMAIN/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Recipients/cn=bob
    
    $adminsessionadsettings.viewentireforest = $true
    
    import-csv c:\batchscripts\x500\x500list.csv -Header Alias,x500 | foreach-object{
        write-host "alias for " $_.Alias " is " $_.x500
        $currentmailbox = Get-Mailbox -domaincontroller "mydc.co.uk" -identity $_.Alias
        $currentmailbox.EMailAddresses.Add($_.x500)
        Set-Mailbox -instance $currentmailbox
    }
    Hope that helps.


    Saturday, July 13, 2013 7:09 PM
  • You can use a tool like LDIFDE or CSVDE to do that.

    Ed Crowley MVP "There are seldom good technological solutions to behavioral problems."

    Sunday, July 14, 2013 4:24 AM
  • Hi,

    Set-Mailbox cant modify LegacyExchangeDN attribute. You will have to change the mailbox LegacyDN using ADSIEDit.msc or some other AD Editor tool.


    Kent Huang
    TechNet Community Support

    Saturday, July 20, 2013 6:27 AM
  • That doesn't modify the legacyExchangeDN property, it adds an X500 address type to the proxyAddresses property of the user.

    --- Rich Matheisen MCSE&I, Exchange MVP

    Sunday, July 21, 2013 1:33 AM