none
Linked mailboxes, changing the target domain RRS feed

  • Question

  • Just inherited a new environment.

    Domain A: EXCHANGE

    Domain B: OLDUSERS

    Domain C: NEWUSERS

    The required trusts are in place.

    Users mailboxes are created on Domain A as "Linked Mailboxes" with the target accounts in Domain B. Domain B is due to be decomissioned and I need to re-target all the mailboxes to accounts in Domain C.

    Performing this task through the GUI is simple enoug. After I have orphaned the mailbox, I simply link it to the new account in Domain C. However I am required to enter a password for each account!

    Two questions:

    1.) What would the Powershell command be for re-linking the mailbox to an account in Domain C

    2.) How can I perform this task without having to know the password of each target account.

    Thanks

    Tuesday, September 3, 2013 9:27 AM

Answers

  • An account that has administrative permissions in Domain C should be enoug for the credentials.

    As for the command, something like this:

    #enter Domain C credentials
    $credential = get-credential
    
    #connect with something like this
    Connect-Mailbox -Identity "<ExchangeGUID>" -Database "<mailboxdatabasename>" -LinkedDomainController "<DomainCotrollerName.DomainC.local>" -LinkedMasterAccount "<LinkedMasterAccountInDomainC>" -LinkedCredential $credential -User "<MailboxDN>" -DomainController "<DomainCotrollerName.DomainA.local>"

    Tuesday, September 10, 2013 2:16 PM

All replies

  • An account that has administrative permissions in Domain C should be enoug for the credentials.

    As for the command, something like this:

    #enter Domain C credentials
    $credential = get-credential
    
    #connect with something like this
    Connect-Mailbox -Identity "<ExchangeGUID>" -Database "<mailboxdatabasename>" -LinkedDomainController "<DomainCotrollerName.DomainC.local>" -LinkedMasterAccount "<LinkedMasterAccountInDomainC>" -LinkedCredential $credential -User "<MailboxDN>" -DomainController "<DomainCotrollerName.DomainA.local>"

    Tuesday, September 10, 2013 2:16 PM
  • Here's something I played with in the past that might be usefull. Provided as-is ... you might be able to modify it for your own needs.

    # Get Domain C credentials (an administratieve accoutn in domain c)
    
    	$credential = get-credential
    
    # You need to create an input file containing the ExchangeGUID attribute and
    # the LinkedMasterAccount attribute-to-be
    	$targetfile = "D:\Mailboxes.txt"
    	$targetMbxData = import-csv $targetfile
    
    
    # GET COLLECTION OF USER MAILBOXES TO BE RECONNECTED AS LINKED MAILBOXES
    # CHANGE THE GET-MAILBOX FILTER TO WHATEVER SUITS YOUR NEEDS
    
    	$collection = Get-Mailbox -OrganizationalUnit "DomainA.local/Users" `
    	| where {$_.displayname -like "Test*" -and $_.RecipientTypeDetails -eq "UserMailbox"} `
    	| select database, distinguishedname,ExchangeGUID
    
    # DISSCONNECT MAILBOXES IN COLLECTION
    
    	$collection | foreach {
    	  # DISCONNECT USER MAILBOX
    	  disable-mailbox  -Identity "$($_.distinguishedname)" -confirm:$false
    	  # DISABLE USER ACCOUNT
    	  dsmod user "$($_.distinguishedname)" -disabled yes
    	}
    
    # RECONNECT SEEMS TO BE WORKING WITHOUT CLEAN-MAILBOX !
     	#get-mailboxdatabase |  Clean-MailboxDatabase 
    
    # IT TAKES EXCHANGE A WHILE TO FIGURE OUT THAT A MAILBOX 
    # HAS BEEN DISCONNECTED, SO WE WAIT (YOU MIGHT NEED TO PLAY WITH THIS)
    
    	Sleep 10
    
    # RECONNECT MAILBOXES IN COLLECTION
    
    	foreach ($mbx in $collection) {
    	  # LOOKUP OLD MAILBOX DATA IN DUMPFILE
    	  $targetMbxDataitem = $targetMbxData | where {$_.ExchangeGUID -eq $mbx.ExchangeGUID}
    	  # RECONNECT MAILBOX AS LINKED MAILBOX
    	  Connect-Mailbox -Identity "$($mbx.ExchangeGUID)" -Database "$($mbx.database)" `
    		-LinkedDomainController "DomainCotrollerName.DomainC.local" -LinkedMasterAccount `
    		"$($oldMbxDataItem.LinkedMasterAccount)" -LinkedCredential $credential -User `
    		"$($mbx.distinguishedname)" -DomainController "vadc104.rotterdam.local"
    	}
    

    to create the targetfile, you might want to export the data before disconnecting from Domin B and then just modify it to what is should be in Domin C (if usernames are the sam, you probablu won't need to modify a lot either) ... something like this ?

    #same statement you use to populate $collection variable
    Get-Mailbox -OrganizationalUnit "DomainA.local/Users" `
    	| where {$_.displayname -like "Test*" -and $_.RecipientTypeDetails -eq "UserMailbox"} `
    	| select database, distinguishedname,ExchangeGUID`
    	| export-csv -notypeinformation "D:\Mailboxes.txt"

    good luck

    Tuesday, September 10, 2013 2:31 PM