Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes bug #2672 and enhancement #2673 #2675

Merged
merged 2 commits into from
Dec 15, 2022
Merged

fixes bug #2672 and enhancement #2673 #2675

merged 2 commits into from
Dec 15, 2022

Conversation

bjoernf73
Copy link
Contributor

@bjoernf73 bjoernf73 commented Dec 15, 2022

Pull Request (PR) description

  • Issue 2673:
    The following is inefficient (and contains the bug of only getting 1000 elements since -ResultSize 'Unlimited' is missing) since it gets the full contact list (or rather the 1000 first) in order to get a single contact:
# line 138
$contactList = Get-MailContact -ErrorAction Stop
$contact = $contactList | Where-Object -FilterScript { $_.Name -eq $Name }

Replacing it with the following makes it more efficient:

$contact = Get-MailContact -Identity $Name -ErrorAction Continue

The -ErrorAction Continue is to allow reaching the test below it; if ($null -eq $contact) { ...

  • Issue 2672:
    The following only get's the first 1000 contacts:
# line 552
[array]$contactList = Get-MailContact -ErrorAction Stop

Adding the -ResultSize 'Unlimited' ensures all contacts are fetched:

# line 552
[array]$contactList = Get-MailContact -ResultSize 'Unlimited' -ErrorAction Stop

This Pull Request (PR) fixes the following issues

@NikCharlebois NikCharlebois merged commit 3b1a61e into microsoft:Dev Dec 15, 2022
@bjoernf73
Copy link
Contributor Author

@NikCharlebois Wow that was fast. So fast that it was actually implemented before my PR;) Thanks anyway :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EXOMailContact: Inefficient use of Get-MailContact EXOMailContact: Max 1000 contacts returned
2 participants