Monitor-MoveRequests.ps1

This article has been ported from my old TechBlog as it is still valid and useful.

I had to painfully watch someone move a mailbox and monitor its progress using Exchange Management Console the other day and I made a note to myself to share my mailbox move bits and pieces, especially a script ”what I writ’ to monitor move requests. I meant to add something to happen when the mailbox move is complete, but haven’t got round to it and can’t be bothered at the present time. Another day.

Here’s the Monitor-MoveRequests.ps1 script:

$moverequests = get-MoveRequest ; get-exchangeserver | ?{$_.IsE14OrLater -eq 'True'}
$A = (get-host).UI.RawUI
$A.WindowTitle = "Monitor Mailbox Move requests"
$B = $A.windowsize
$B.width = 150
$B.height = 65
$A.WindowSize = $B
while ($true) {cls; foreach ($moverequest in $moverequests) {Get-MoveRequestStatistics $moverequest | select Alias, DisplayName, StartTimestamp, TotalQueuedDuration, PercentComplete, BytesTransferred, StatusDetail, SourceDatabase, TargetDatabase,Status, TotalinProgressDuration, OverallDuration}
;sleep 5}


It may look familiar; I modified another script to make it

Here’s the rest of the stuff:

Test mailbox is ready to move:

New-MoveRequest -Identity user01@company.com -TargetDatabase "MDB01" –whatif

Move a mailbox:

New-MoveRequest -Identity user01@company.com -TargetDatabase "MDB01"

Clear a mailbox move request:

Get-MoveRequest | where {$_.status -eq "Completed"}

Clear all move requests:

Get-MoveRequest | where {$_.status -eq "Completed"} | Remove-moverequest -confirm:$False

New mailbox creation:

New-Mailbox -Name 'user01' -Alias 'user01' -OrganizationalUnit 'company.local/staff' -UserPrincipalName 'user01@company.com>' -SamAccountName 'user01' -FirstName 'user01' -Initials '' -LastName '' -ResetPasswordOnNextLogon $false -Database MDB01

Multiple move requests (enter in a ps1 script):

New-MoveRequest user01 -TargetDatabase "MDB01" -suspend
New-MoveRequest user02 -TargetDatabase "MDB02" -suspend


Start multiple move requests (enter in a ps1 script e.g. ResumeMailboxMoves.ps1):

Get-MoveRequest | Resume-MoveRequest

Powershell script as a batch file (e.g. for scheduling using Task Scheduler)(where ‘D:\Exchange’ is the Exchange install path):

PowerShell.exe -command ". 'D:\Exchange\bin\RemoteExchange.ps1'; cls; Connect-ExchangeServer -auto; & 'D:\Exchange\Scripts\ResumeMailboxMoves.ps1'"