New-MailboxRestoreRequest bulk mailbox merge : how to do that

I was asked by some one if we can do new-mailboxrestorerequest for all the
users. Well on the first thought I said it is possible.

It took some time but I was able to get it working.

 

SCRIPT :

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

foreach($mailbox in Get-MailboxStatistics -Database RDB)
{New-MailboxRestoreRequest -SourceDatabase RDB -SourceStoreMailbox
$mailbox.DisplayName -TargetMailbox $mailbox.DisplayName}

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

 

NOTE: In the above example RDB is the name of the Recovery Database

 

PLEASE CHECK FOR THE SPACES when you copy paste the
script.