Recipe 17.16. Moving a MailboxProblemYou want to move a mailbox to a new database, storage group, or server. SolutionUsing a graphical user interface
Using a command-line interface> exchmbx -b <UserDN> -move "<server>:<storage group>:<mail store>" Or alternatively, run the following command: > exchmbx -b <UserDN> -move "<Home MDB URL>" Replace <UserDN> with the user's distinguished name, <server> with the Exchange server name, <storage group> with the storage group, <mail store> with the mail store, and <Home MDB URL> with the full homeMDB URL for the desired mailbox store. To move an existing mailbox for user joe to Exchange Server Srv1, Storage group SG1, and mailbox store DB1, execute the following command: > exchmbx -b "cn=joe,cn=users,dc=rallencorp,dc=com" -move "srv1:sg1:db1" Using VBScript' This code moves a mailbox. ' ------ SCRIPT CONFIGURATION ------ strUserDN = "<UserDN>" ' e.g., cn=jsmith,cn=Users,dc=rallencorp,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." DiscussionMailbox moves are commonly done in many Exchange organizations due to servers getting upgraded, server hardware issues, users migrating from Exchange 5.5 to Exchange 2003, or the administrators wanting to readjust mailbox location for load balancing.
A mailbox move is an odd operation in terms of permissions. Logically, moving a mailbox is basically a combination of create and delete operations, which is something an Exchange Data Administrator can do just fine. However, to actually move a mailbox, you must have Exchange Administrator Role permissions with a subset of the permissions Exchange Data Administrator have on users. See MS KB 842033 for details of the permissions needed. If you don't handle user mailbox administration through an automated web site, I recommend that you delegate permissions to the attributes listed in the knowledge base articles to some Active Directory group. Once delegated, add the Exchange Administrator Role users to that group and have them handle all mailbox moves. Using a graphical user interfaceThe move mailbox wizard is the only Exchange wizard that allows you to schedule when the changes will be made. This is obviously a handy feature for mailbox moves because it isn't something you generally want to do midday. This allows Exchange administrators who like to sleep at night to schedule the work to be done, and go home with everyone else. Using a command-line interfacePrior to the ExchMbx tool, there was no simple way to move a mailbox from the command line. The command structure to move a mailbox is similar to the command structure to create a mailbox (see the command-line solution in Recipe 17.11).
Using VBScriptThe trickiest part of moving a mailbox for a user is to know what the Home MDB URL is for the database where you want to move the user. The method used here allows you to specify three well-known components and arrive at the answer. In Recipe 17.11, I use another method to do this by entering the exact value for the mailbox store URL. A third alternative would be to search Active Directory for all valid homeMDB values, display them, and have the person running the script select from the list like ADUC does. To get the list of mailbox store URLs, search against the Configuration container in Active Directory (e.g., cn=Configuration,dc=rallencorp,dc=com) with the following filter (objectCategory=msExchPrivateMDB). See AlsoMS KB 842033 ("Access Denied" error message when you move mailboxes by using the Exchange Task Wizard in Exchange Server 2003), MS KB 316792 (Minimum permissions necessary to perform Exchange-related tasks), and MS KB 821829 (Moving Mailboxes in Exchange Server 2003) |