grahamr975 / EWS-Office365-Contact-Sync

Uses Exchange Web Services to synchronize a Global Address List in Office 365 to a user's mailbox
MIT License
99 stars 21 forks source link

ExchangeOnlineManagement version limits #73

Closed Bananovics closed 1 year ago

Bananovics commented 1 year ago

Hi,

Script is working fine with ExchangeOnlineManagement version 2.0.5 but it is not with 3.0.0. Similar issue described here: https://learn.microsoft.com/en-us/answers/questions/1023619/connect-exchangeonline-write-errormessage-expired.html

Can you please update commands in your script to solve limitations with version 3.0.0?

christianneeb commented 1 year ago

Adding to that this announcement from Microsoft: https://techcommunity.microsoft.com/t5/exchange-team-blog/announcing-deprecation-of-remote-powershell-rps-protocol-in/ba-p/3695597

grahamr975 commented 1 year ago

Thanks for the heads up. I will push out an update for v3.0.0 compatibility before the depreciation.

ggogel commented 1 year ago

I can confirm this. As soon as you use any version higher than 2.0.5, the issue occurs. Though the issue only seems to occur with certificate-based authentication and only if you try to get more than 1000 objects. If I just run Connect-ExchangeOnline and run (Get-Contact).Count, the error does not appear and I get the full amount of contacts.

ggogel commented 1 year ago

What are the Exchange Management v3 equivalents to the Cmdlets Get-User, Get-Contact, and Get-MailContact? The documentation does not list any equivalents for them.

Get-Command Get-Ex*

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Function        Get-EXCAllContactFolders                           1.7.0.0    ExchangeContacts
Function        Get-EXCContact                                     1.7.0.0    ExchangeContacts
Function        Get-EXCContactFolder                               1.7.0.0    ExchangeContacts
Function        Get-EXCContactGroup                                1.7.0.0    ExchangeContacts
Function        Get-EXCContactGroups                               1.7.0.0    ExchangeContacts
Function        Get-EXCContacts                                    1.7.0.0    ExchangeContacts
Function        Get-EXCDumpsterContacts                            1.7.0.0    ExchangeContacts
Function        Get-EXCPrivacyReport                               1.7.0.0    ExchangeContacts
Cmdlet          Get-ExecutionPolicy                                3.0.0.0    Microsoft.PowerShell.Security
Cmdlet          Get-EXOCasMailbox                                  2.0.5      ExchangeOnlineManagement
Cmdlet          Get-EXOMailbox                                     2.0.5      ExchangeOnlineManagement
Cmdlet          Get-EXOMailboxFolderPermission                     2.0.5      ExchangeOnlineManagement
Cmdlet          Get-EXOMailboxFolderStatistics                     2.0.5      ExchangeOnlineManagement
Cmdlet          Get-EXOMailboxPermission                           2.0.5      ExchangeOnlineManagement
Cmdlet          Get-EXOMailboxStatistics                           2.0.5      ExchangeOnlineManagement
Cmdlet          Get-EXOMobileDeviceStatistics                      2.0.5      ExchangeOnlineManagement
Cmdlet          Get-EXORecipient                                   2.0.5      ExchangeOnlineManagement
Cmdlet          Get-EXORecipientPermission                         2.0.5      ExchangeOnlineManagement

All Cmdlets Get-EXCContact* seem to be related to user mailbox contacts.

Bananovics commented 1 year ago

Thanks for the heads up. I will push out an update for v3.0.0 compatibility before the depreciation.

Hi! Can you please give update when the v3.0.0 update is expected?

grahamr975 commented 1 year ago

Hi! Can you please give update when the v3.0.0 update is expected?

@Bananovics I'm aiming for early/mid-June.

grahamr975 commented 1 year ago

I've opened a ticket with Microsoft and am awaiting feedback. The new version of ExchangeOnline broke the Get-User function when returning 1000+ users. There are more details about the bug linked below...

https://github.com/MicrosoftDocs/office-docs-powershell/issues/10907

pleongomez commented 1 year ago

Hi, same issue with get-unifiedgroup function, is this broke too, like Get-User?

Thanks, Regards.

grahamr975 commented 1 year ago

@pleongomez I think so. From what I've experienced, all of the non-ExO commands fail when returning 1000+ objects. Specifically, when using certificate authentication with 3.1.0 REST API. Hopefully, Microsoft gets back to me soon.

Bananovics commented 1 year ago

I found a comment here: https://techcommunity.microsoft.com/t5/exchange-team-blog/announcing-deprecation-of-remote-powershell-rps-protocol-in/ba-p/3695597/page/2#comments

Says: "UPDATE: issue has been resolved. Just in case anybody else is getting the weird 'Expired or Invalid pagination request' error when using REST to fetch more than 1000 objects: apparently, you get this issue if you aren't using the .onmicrosoft.com domain for the -Organization parameter (although this does work in most cases). Documentation for Connect-ExchangeOnline does state that 'you must use the primary .onmicrosoft.com domain of the organization', so be sure to check that."

I do not know if it helps but I thought it's worth to sharing

grahamr975 commented 1 year ago

Just an update: Microsoft responded to our ticket by saying that the behavior is currently "by design" and to leave feedback here: https://feedbackportal.microsoft.com/feedback/post/. I'll have to find another workaround.

grahamr975 commented 1 year ago

I found a comment here: https://techcommunity.microsoft.com/t5/exchange-team-blog/announcing-deprecation-of-remote-powershell-rps-protocol-in/ba-p/3695597/page/2#comments

Says: "UPDATE: issue has been resolved. Just in case anybody else is getting the weird 'Expired or Invalid pagination request' error when using REST to fetch more than 1000 objects: apparently, you get this issue if you aren't using the .onmicrosoft.com domain for the -Organization parameter (although this does work in most cases). Documentation for Connect-ExchangeOnline does state that 'you must use the primary .onmicrosoft.com domain of the organization', so be sure to check that."

I do not know if it helps but I thought it worth to share.

@Bananovics Thanks for researching this. Unfortunately, I still experience the same issue even when using our .onmicrosoft.com domain. Maybe someone else could have better luck?

grahamr975 commented 1 year ago

I finally figured this out by throwing everything at the wall and seeing what stuck. For some reason, including the "ConnectionURI" parameter with the Connect-ExchangeOnline cmdlet was the culprit. After removing this, everything is working fine. A new version is coming soon.

grahamr975 commented 1 year ago

Resolved by commit 06e195781665c44f3e9a63052953d64ff4148f39, please see the latest version.