locked
Move only mailboxes below a certain size (via powershell) RRS feed

  • Question

  • I use the following command to get all mailboxes below a certain size from a specific database:

    Get-Mailbox -database database_db10 | get-mailboxstatistics | where {$_.TotalItemSize -lt 10MB}

    This returns the correct data (all mailboxes less than 10Mb) but when I try to then pipe that to a new-moverequest I'm getting an error:

    Command:

    Get-Mailbox -database database_db10 | get-mailboxstatistics | where {$_.TotalItemSize -lt 10MB} | new-moverequest -targetdatabase database_db12

    Error:

    Cannot process argument transformation on parameter 'Identity'. Cannot convert the "2db1965d-9f45-44cd-b9ad-ccf76895d391" value of type "Microsoft.Exchange.Data.Mapi.MailboxId" to type "Microsoft.Exchange.Configuration.Tasks.MailboxOrMailUserIdParameter".+ CategoryInfo          : InvalidData: (Microsoft.Excha...ilboxStatistics:PSObject) [New-MoveRequest], ParameterBindin...mationException+ FullyQualifiedErrorId : ParameterArgumentTransformationError,New-MoveRequest

    It looks like it's passing the ExchangeGUID instead of the mailbox alias.  Is there another way to do this (move only mailboxes less than a certain size)?  Were migrating 2003 mailboxes but the log luns are only 20gb so we need an easy way to only select about 10gb of mailboxes to move each night (from each database).  Too bad the mailbox size is not exposed in the EMC as this would be easy to do this from there.  

     

    Thanks.

     

    Friday, January 13, 2012 6:58 PM

Answers

  • Hi tbooher,

    To first answer your question, you should be able to accomplish the task by turning around your script a little bit so it looks like this:

    Get-MailboxDatabase database_db10 | get-mailboxstatistics | where {$_.TotalItemSize -lt 10MB -AND $_.DisplayName -notlike "SystemMailbox*"} | get-mailbox | New-MoveRequest -TargetDatabase database_db12


    There are probably other ways to accomplish your end goal as well.  Here's a good article on balancing mailboxes across Exch10 (and Exch07) databases, if it helps at all:   http://www.stevieg.org/2010/09/balancing-exchange-databases/

    -Matt

    • Proposed as answer by Peddy1st Friday, January 13, 2012 8:51 PM
    • Marked as answer by tbooher Friday, January 13, 2012 9:37 PM
    Friday, January 13, 2012 8:15 PM

All replies

  • Hi tbooher,

    To first answer your question, you should be able to accomplish the task by turning around your script a little bit so it looks like this:

    Get-MailboxDatabase database_db10 | get-mailboxstatistics | where {$_.TotalItemSize -lt 10MB -AND $_.DisplayName -notlike "SystemMailbox*"} | get-mailbox | New-MoveRequest -TargetDatabase database_db12


    There are probably other ways to accomplish your end goal as well.  Here's a good article on balancing mailboxes across Exch10 (and Exch07) databases, if it helps at all:   http://www.stevieg.org/2010/09/balancing-exchange-databases/

    -Matt

    • Proposed as answer by Peddy1st Friday, January 13, 2012 8:51 PM
    • Marked as answer by tbooher Friday, January 13, 2012 9:37 PM
    Friday, January 13, 2012 8:15 PM
  • Thanks for the tip on changing the order, that did the trick.  I'll take a look at the URL as well.

     

    Todd

    Friday, January 13, 2012 9:37 PM
  • This did not work for me on SP2, i get all mailboxes even if i specify a specific database with -Database or a specific server with -Server. Any clues?

    Edit: Actually, this may be because of uncleared completed move requests. I will clear those and try the command again.

    Edit2: Same thing happens after clearing all completed move requests. Forgot to say we have two sites and i tested the command in both. Last site replication was 15 minutes ago so it isn't that.



    • Edited by fr33k Wednesday, May 23, 2012 6:07 PM
    Wednesday, May 23, 2012 3:58 PM