Move mailbox (VBScript)

This code can be found in Chapter 5 of Exchange Server Cookbook

Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.

Find out how to download all of the VBScript code from this site.

' This script was originally published in the Exchange Cookbook,
' (http://www.exchangebookcook.com). Written by Paul Robichaux, 
' Missy Koslosky, and Devin Ganger. Redistributed with permission 
' of the publisher, O'Reilly & Associates.

' This code moves the target mailbox to the specified server. 

' ------ SCRIPT CONFIGURATION ------
 strServerName = "<dc>" ' e.g. "BATMAN"	
 strForest= "<forestDN>"	' e.g. dc=robichaux, dc=net"
 strUser= "<userName>"	' e.g. "Missy Koslosky" 
 strTargetName = "<targetMDB>" ' e.g. "/CN=Mailboxes,CN=First Storage Group, CN=InformationStore,"
 strServerContainer = ",CN=servers,cn=<adminGroup>," &_
     "CN=administrative groups,cn=<orgName>,cn=" &_
     "Microsoft Exchange,cn=Services,cn=configuration," & strDomain
 ' e.g. ",CN=servers,cn=First Administrative Group,CN=administrative groups,cn=Robichaux and Associates,cn=Microsoft Exchange,cn=Services,cn=configuration," & strDomain
' ------ END CONFIGURATION ---------

' get the target user object 
what = "LDAP://" & strServerName & "/CN=" & strUser &_
    ",CN=users," & strDomain
Set objUser = GetObject(what)
Set objMailbox = objUser

strTargetMDB = "LDAP://" + strServerName + strTargetName
strTargetMDB = strTargetMDB + "CN=" & strServerName &_
  strServerContainer
objMailbox.MoveMailbox strTargetMDB
objUser.SetInfo
WScript.Echo "Moved mailbox for " & strUser & " to  & strTargetName

This code has been viewed 2888 times.

New from the creators of TechTasks.com: StatSheet.com