Unexpected results using Get-Mailbox cmdlet in parallel

Eliya G 1 Reputation point
2021-12-15T07:00:24.763+00:00

I got unexpected results using the Get-Mailbox cmdlet.

My code is making 17 calls in parallel of the same command with a different filter parameter, each call should return the correct result for the specific filter:
Get-Mailbox -ResultSize Unlimited -RecipientTypeDetails UserMailbox -Filter "ExternalDirectoryObjectId -like '<hex>*'".

We sum all the calls results and expect to get the total count of the mailboxes with RecipientTypeDetails UserMailbox.

The problem is that some calls return 0 results instead of returning the correct one (although there are actual results that should be returned - running the same cmdlet on PS returns a result), therefore the sum of all the calls isn’t accurate to the sum we expect to.

The issue is not on a specific filter, it’s random (therefore the total results are not always the same).

What could be the reason for those results?

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,462 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Limitless Technology 39,511 Reputation points
    2022-01-06T15:06:48.053+00:00

    Hi there,

    It’s a good idea to replace older calls to the Get-Mailbox cmdlet with Get-ExoMailbox. However, it’s not just a matter of cut and paste updates. In some cases, the nature of the new REST-based cmdlets mean that some additional care is necessary to ensure that the updated code works as expected.

    You can get more info from here https://techcommunity.microsoft.com/t5/exchange/using-filters-with-the-get-exomailbox-cmdlet/m-p/2466152

    Hope this resolves your Query!!


    --If the reply is helpful, please Upvote and Accept it as an answer--

    0 comments No comments