Exchange 2010 and 2007: Some sort of batching for Get-Mailbox if there are more than 100000 mailboxes ? RRS feed

  • Question

  • Hello All,

    We have a C# application to get mailboxes from exchange server.

    We make use of

    Get-Mailbox -ResultSize Unlimited -ReadFromDomainController

    cmdlet to get all mailboxes.

    This works fine if there are say less number mailboxes on exchange server (Even though initial time taken to see the result increases as number of mailboxes increases).

    In our environment, we have more than 200,000   mailboxes (in same DC and in same OU). With the above cmdlet has serious issues like it takes a lot of time (in hours) to the result and also the c# application consumes lot of memory.

    Is there a way to get mailboxes in batches ? like we have VLV in ADSI ?

    If there is no direct implementation provided, can I use below approach ?

    1. Run Get-Mailbox -SortBy Alias -ResultSize 1000
    2. Store the last Alias returned in our C# in '$LatestAlias' variable
    3. Fire 'Get-Mailbox -SortBy Alias -ResultSize 1000 -Filter {Alias -GT $LatestAlias}'

    Repeat step#3 till we get all mailboxes.

    The above looks fine ? Any issues in this?

    Please help.


    Tuesday, June 18, 2013 7:29 AM

All replies

  • I know this reply is probably too late, but I will offer my observation from my own attempt at doing pretty much the same thing.

    The above solution looks like it should work but I ran into a little gotcha or bug.  In my own test, it seemed to work fine so long as the aliases all were alphanumeric.  Once it reached aliases that were not purely alphanumeric, it broke.  I have yet to confirm, but it acts as if the method it uses to sort aliases for the SortBy does NOT match the method that is used to sort  for the -GT comparison.  So for one, hyphens are sorted somewhere before 'a' but the other sorts the hyphens somewhere after 'z'.

    Tuesday, November 5, 2013 1:28 AM
  • Hi Pete - There is definitely some bug in sorting and filtering. This approach when I tried, it skipped many records without any errors!


    Tuesday, November 5, 2013 4:43 AM