January 2006
Beginner
832 pages
27h 52m
English
There are times when you want to move mailboxes from one Exchange server to another. The reason for the move may be for a migration from an older Exchange server to a new one (e.g., Exchange 5.5 to Exchange 2003), to better load balance mailboxes between Exchange Servers, or any number of other reasons. This is a very simple task to handle through a CDOEXM script. The following code shows how to move a mailbox:
' This code moves a mailbox.
Option Explicit
Dim strUserDN, strServer, strSGName, strMailStoreName, strSearch
Dim objSrv, strSg, strSGUrl, strMBUrl, objUser
' ------ SCRIPT CONFIGURATION ------
strUserDN = "<UserDN>" ' e.g. cn=DrAmy,cn=Users,dc=mycorp,dc=com
strServer = "<Exchange Server>" ' e.g. ExchServer2
strSGName = "<Storage Group Name>" ' e.g. SG1
strMailStoreName = "<MailBox Store Name>" ' e.g. DB1
' ------ END CONFIGURATION ---------
' Find Storage Group URL and Generate Mailbox Store URL
strSearch = "cn=" & strSGName & ","
Set objSrv = CreateObject("CDOEXM.ExchangeServer")
objSrv.DataSource.Open strServer
For Each strSg In objSrv.StorageGroups
If (instr(1,strSg,strSearch,1)>0) Then
strSGUrl = strSg
Exit For
End If
Next
strMBUrl = "LDAP://cn=" & strMailStoreName & "," & strSGUrl
' Attach to user and move mailbox
Set objUser = GetObject("LDAP://" & strUserDN)
objUser.MoveMailbox(strMBUrl)
WScript.Echo "Successfully moved mailbox."Moving a mailbox requires Exchange Service Administrator permissions, plus additional permissions on user objects. ...