Friday, July 9, 2010

Track Mass Exchange Mailbox Moves

Moving a mailbox or two between Exchange databases and/or servers isn’t too hard to keep track of, but what if you’re moving 200?  Or 2000?  I came up with a little “one-liner” (can we really call a do loop a one-liner?) while migrating the bulk of our mailboxes from Exchange 2003 to 2010.  Hopefully you can use it to help you keep an eye on things too.  Here’s the script, first in a more traditional form, then in one-liner form for easy copy and paste into a shell session.  It’s a do {} until ($false) loop so you have to Ctrl-C to break out of it.

Traditional Script Form

  $mr = Get-MoveRequest

  $mr | Group –Property Status | Select Name,Count | Format-Table –auto
  $mr | Where { $_.status –eq “InProgress” } | Select DisplayName,TotalMailboxSize,PercentComplete |
    Format-Table –auto
  Start-Sleep –seconds 60
} until ($false)

One-Liner Form

do { cls ; $mr = Get-MoveRequest ; $mr | group status | select Name,Count | ft –auto ; $mr | ? { $_.status –eq “InProgress” } | select DisplayName,TotalMailboxSize,PercentComplete | ft –auto ; sleep –seconds 60 } until ($false)

Hope you find that helpful!