none
Performance issues with Get-Mailbox -Database PowerShell cmdlet RRS feed

  • Question

  • Hello,

    I have a database with say around 5000 users. My below non-fancy cmdlet takes close to 4 mins for getting the mailbox objects. Is there a way I can speed it up?

    Get-Mailbox -Database -resultsize unlimited

    I would love to bring this down to less than 2 minutes if possible. I have tried with result sets of 1K and smaller, but that doesn't help.

    I thought about doing an LDAP query instead on relying on Exchange cmdlet, but looks archiveName property is not stored in AD and my application needs that property.

    By the way, I have three databases in my environment with around 8K users, if I run the cmdlet concurrently, it hogs up whole of my cpu and takes close to 7 minute.

    Thanks

    Tuesday, December 3, 2013 1:11 AM

Answers

  • Hi,

    One can try to get better performance by spawning these cmdlets in parallel for mailbox database on the machine, but then too the performance of a Get-MailboxDatabase on a database with 5k to 10k users is dismal. Also, doing it in parallel, results in high CPU usage...(even with 3 such cmdlets running simultaneously)

    I guess this is because of some sort of horrible cross join between information in Jet database and AD...and one may need to submit a ticket with MS and hope they will resolve it...

    Thanks

    • Marked as answer by Varun Mohta Tuesday, January 14, 2014 4:19 PM
    Tuesday, January 14, 2014 4:19 PM

All replies

  • Hi

    do you want to view the results on the shell or export them to CSV? Most likely when your CPU spikes your end users lose connection or outlook hangs? correct? 

    How are your servers spec'd?

    Tuesday, December 3, 2013 4:56 AM
    Moderator
  • I am developing an application for enterprise customers.  So, server configuration would be pretty good.

    I am invoking cmdlets using the automation namespace.By the way, it doesn't matter I see the same performance on the shell/export too...

    I want to avoid the CPU spike, end users getting impacted etc..but can't figure out how to run this cmdlet in an efficient manner...

    Tuesday, December 3, 2013 6:11 AM
  • Hi,

    You can look into substitue of this command.

    1. You can query mailboxes per organizationalUnit

    Get-Mailbox -organizationalunit ou_path_here -ResultSize Unlimited

    or

    Get-Mailbox -organizationalunit ou_name_here -ResultSize Unlimited

    ou_name shud be unique in AD.

    2. You can query mailboxes based on customAttribute

    Get-Mailbox -Filter {CustomAttribute1 -eq 'som_value_here'} -ResultSize Unlimited

    3. You can query mailboxes based on UserPrincipalName

    Get-Mailbox -Filter {UserPrincipalName -like '*@domain.tld'} -ResultSize Unlimited

    I would suggest to explore alternate way to get desired mailboxes.

    Regards,


    Laeeq Qazi|Team Lead(Exchange + Sharepoint + BES + DynamicsCRM) www.HostingController.com

    Tuesday, December 3, 2013 12:51 PM
  • I need all the mailboxes inside a database. So,  I am already doing a restrictive query Get-Mailbox -Database. Even if I narrow it down further say by figuring out all the OUs and then do a loop to get all the mailboxes inside a database for these OUs, it wouldn't help much

    Tuesday, December 3, 2013 2:03 PM
  • Hi,

    I always try to resort to alternate commands if some command doesn't run in expected time duration.

    May be this is not good approach, but I would suggest to give it a Try:

    First tag all your mailboxes with mailbox db name:

    Get-mailbox -database "dbName" -ResultSize Unlimited |set-mailbox -CustomAttribute15 "dbName"

    [Above cmd can be made generic as each mailbox has -Databaes attribute]

    now get your mailboxes using customAttribute15

    Get-Mailbox -Filter {CustomAttribute15 -eq "DbName"}

    Regards,


    Laeeq Qazi|Team Lead(Exchange + Sharepoint + BES + DynamicsCRM) www.HostingController.com


    Thursday, December 5, 2013 10:41 PM
  • Hi,

    The return time may be affected by a lot of causes. It can be either DC, Exchange, network, MAPI performance issues.

    Due to the complex, I suggest it’s better to contact a Microsoft Support to find the root cause.

    Thanks,

    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact tnsfl@microsoft.com


    Simon Wu
    TechNet Community Support

    Saturday, December 7, 2013 2:59 PM
    Moderator
  • Hi,

    Is there any update on this thread?

    Thanks,

    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact tnsfl@microsoft.com


    Simon Wu
    TechNet Community Support

    Saturday, December 14, 2013 4:47 AM
    Moderator
  • Hi,

    One can try to get better performance by spawning these cmdlets in parallel for mailbox database on the machine, but then too the performance of a Get-MailboxDatabase on a database with 5k to 10k users is dismal. Also, doing it in parallel, results in high CPU usage...(even with 3 such cmdlets running simultaneously)

    I guess this is because of some sort of horrible cross join between information in Jet database and AD...and one may need to submit a ticket with MS and hope they will resolve it...

    Thanks

    • Marked as answer by Varun Mohta Tuesday, January 14, 2014 4:19 PM
    Tuesday, January 14, 2014 4:19 PM