Solved

move mailbox with conditional - from one store to another store

Posted on 2012-03-09
20
818 Views
Last Modified: 2012-03-12
Hi - exchange power shell experts,

I have a questions about move mailbox from one store to another store on a same server.
i know we can use:
get-mailbox -database "DB1" | move-mailbox -targetdatabase "DB2" –MaxThreads 4
this will move all mailbox in DB1 to DB2.

we have a large DB1 and i have to break it into 2-3 small DBs in different SGs.
I could not just move everything at once and there are over thousands of mailboxes as well.

is there a way to move them by size group.
like 0-100MB, 101-200MB...

Thanks a lot!

Robin
0
Comment
Question by:robinyanwang
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 11
  • 5
  • 4
20 Comments
 
LVL 13

Expert Comment

by:Felix Leven
ID: 37703392
Test on Test Mailbox first please:
Get-MailboxStatistics | Where {$_.TotalItemSize -lt 100MB} | Move-Mailbox -TargetDatabase "yourserver\Mailbox Database"

Moves Mailboxes smaller then 100 MB
0
 

Author Comment

by:robinyanwang
ID: 37703401
i also know
Get-MailboxDatabase "DB1" | Get-MailboxStatistics | Sort DisplayName | Select @{Name="TotalItemSize(MB)";Expression={$_.TotalItemSize.Value.ToMB()}}, DisplayName | ? {$_.'TotalItemSize(MB)' -lt 100}

this will show all mailboxes in DB1 with total size under 100MB.

I do not know how to combine them together with move-mailbox...
0
 
LVL 13

Expert Comment

by:Felix Leven
ID: 37703440
Test on Test Mailbox first please:
Get-MailboxDatabase "DB1" | Get-MailboxStatistics | ? {$_.'TotalItemSize(MB)' -lt 100} | Move-Mailbox -TargetDatabase "yourserver\Mailbox Database"
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:robinyanwang
ID: 37703593
it does not work.

i can out put these mailboxes either with get-mailbox,  or get-mailboxdatabase
between 100-200MB, when i tried to combine with move-mailbox, it does not work.
0
 
LVL 13

Accepted Solution

by:
Felix Leven earned 250 total points
ID: 37703678
exchange 2010:

Get-MailboxDatabase db1 | get-mailboxstatistics | where {$_.TotalItemSize -lt 100MB | get-mailbox | New-MoveRequest -TargetDatabase yourdb

exchange 2007 = Move-Mailbox
0
 

Author Comment

by:robinyanwang
ID: 37703771
[PS] C:\>move-mailbox "ann.james@uaz.com" -targetdatabase "staff db"
Cannot open the log file 'C:\Program Files\Microsoft\Exchange Server\Logging\MigrationLogs\move-Mailbox20120309-160647-
1895865.log'.
At line:1 char:1
+  <<<< move-mailbox "ann.james@uaz.com" -targetdatabase "staff db"
    + CategoryInfo          : InvalidOperation: (:) [], InvalidOperationException
    + FullyQualifiedErrorId : 960CAC4


I can not even run move-mailbox cmdlet...am i typing something wrong? i am using ex2k7...
0
 
LVL 9

Assisted Solution

by:chrismerritt
chrismerritt earned 250 total points
ID: 37703783
Looks like you lack permissions on the path specified to create the .log file. Try running the Exchange Shell window as admin.
0
 
LVL 13

Expert Comment

by:Felix Leven
ID: 37703788
But you run the exchange console as (exchange) Admin ?
0
 

Author Comment

by:robinyanwang
ID: 37703791
i am a domain admin and i can move mailbox using EMC without any problem
0
 
LVL 9

Expert Comment

by:chrismerritt
ID: 37703795
doesn't matter. In Server 2008 you still need to run Exchange Shell as admin to do certain tasks sometimes.
0
 

Author Comment

by:robinyanwang
ID: 37703797
so...where i can add my self then?
0
 

Author Comment

by:robinyanwang
ID: 37703818
just added myself as exchange admin...
0
 
LVL 9

Expert Comment

by:chrismerritt
ID: 37703825
you just right click the exchange shell executable and choose run as admin, same as anything else you run as admin in Windows! :)
0
 

Author Comment

by:robinyanwang
ID: 37703849
haaaa. yes, i can now...a mailbox is moving...now we can back to track of testing size group moving...
0
 

Author Comment

by:robinyanwang
ID: 37703865
WORKING now!!!

so great guys...save me tons of time...you are very nice people!
0
 

Author Comment

by:robinyanwang
ID: 37703926
last little thing,
Get-MailboxDatabase "staff db" | Get-MailboxStatistics | where {$_.TotalItemSize -lt 50MB} | where {$_.TotalItemSize -ge 1MB}

it returns lots of mailbox, how to do the item count?
I would like to know how many mailbox in certain range...

I will raise the point to 500 for you guys. you have a nice weekend.
0
 
LVL 9

Expert Comment

by:chrismerritt
ID: 37703938
You shouldn't need to chain Where statements, this should work:

Get-MailboxDatabase "staff db" | Get-MailboxStatistics | where {$_.TotalItemSize -lt 50MB -and $_.TotalItemSize -ge 1MB}

To count the objects you have a couple of choices really:

Measure-Object {
Get-MailboxDatabase "staff db" | Get-MailboxStatistics | where {$_.TotalItemSize -lt 50MB -and $_.TotalItemSize -ge 1MB}
}

Encasing your command in this will count the number of returned objects.

Also you could do it like this:

$MailboxList = Get-MailboxDatabase "staff db" | Get-MailboxStatistics | where {$_.TotalItemSize -lt 50MB -and $_.TotalItemSize -ge 1MB}
$MailboxList.Count

Happy if you want to split the points :)
0
 

Author Comment

by:robinyanwang
ID: 37704142
Hi about count -

when i tried the measure-object, it does not give me the number, it returns to c:\>

do i have to type an 'enter' at each line, - to break it into different lines?

thanks.
0
 

Author Comment

by:robinyanwang
ID: 37704149
the second $list.count works!...just do not know why the first measure-object does not work.
0
 
LVL 9

Expert Comment

by:chrismerritt
ID: 37704456
You got one method that works, why worry about the other? :)
0

Featured Post

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
Unified and professional email signatures help maintain a consistent company brand image to the outside world. This article shows how to create an email signature in Exchange Server 2010 using a transport rule and how to overcome native limitations …
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question