Here's a simple script for moving mailboxes, I talked about how to schedule an Exchange 2007 script in the last post. Here's what it does:
Yes, we could certainly do more sophisticated things, such as find the smallest Mailbox Store and move users there, or format the XML logs better, but hey, I ran out of time. :-) Just copy the below to a .ps1 file.
############################## ## Exchange 2007 Migration ## Move-mailbox script ## Date & Author ## ##############################
# NOTE: to run PowerShell scripts, you need to set the PS execution poloicy "set-executionpolicy unrestricted"
# load the list of users - this must be 1 user alias per line# the user list file must be in the same directory as this script
$users = get-content MoveMbx1.txt
# move em to a specific target database using 10 threads
$users | move-mailbox -TargetDatabase "MailboxServer\StorageGroup01\MailboxStore01" -MaxThreads 10 -confirm:$false
# put today's date in a variable
$date=get-date -uformat "%Y%m%d"
# read today's migration log and store it as $EMailBody
$EmailBody = get-content "C:\Program Files\Microsoft\Exchange Server\Logging\MigrationLogs\*$date*.xml"
# when done, send us an email with the log text
$SmtpClient = new-object system.net.mail.smtpClient $MailMessage = New-Object system.net.mail.mailmessage $SmtpClient.Host = "smtpserver.domain.com" $mailmessage.from = ("<emailaddress>@domain.com") $mailmessage.To.add("<emailaddress>@domain.com") $mailmessage.Subject = “MoveMbx1.ps1 script has completed” $mailmessage.Body = $EmailBody $smtpclient.Send($mailmessage)