Assistance needed with Hybrid Exchange 2013 to EXO MEPF with Sync-ModernMailPublicFolders.ps1 script

DamokMS 1 Reputation point
2022-09-23T01:15:41.423+00:00

Hi All,

As the title suggest, I am having a bit of an issue with our Hybrid Exchange environment which is a Exchange 2013 to EXO set up, we managed to get the Public Folders synced and visible/available to the EXO users, but we are having a hard time with the Mail Enabled Public Folders sync.

We attempted to follow this article from Microsoft in order to achieve this: https://video2.skills-academy.com/en-gb/exchange/hybrid-deployment/set-up-modern-hybrid-public-folders

But we've run into issues with the script straight away when first run, the script gets through the initial check and validation of the Mail enabled Public Mail folders, but then gives us the following error which makes not much sense to me in regards to the Exchange version:

PS C:\Temp\PublicFolders> .\Sync-ModernMailPublicFolders.ps1 -csvSum
maryFile:sync_summary.csv -WhatIf
[23/09/2022 10:23:35 AM] Downloading ValidateMailEnabledPublicFolders script...
Checking for mail-enabled System folders...
Found 0 mail-enabled System folders.
Getting all public folders. This might take a while...
Found 907 public folders.
13 of those are mail-enabled.
0 folders are mail-enabled with no AD object.
13 folders are mail-enabled and are properly linked to an existing AD object.
Getting all MailPublicFolder objects...
0 MailPublicFolders are orphaned.
Building EntryId HashSets...
0 orphaned MailPublicFolder objects.
0 of those orphans point to mail-enabled folders that point to some other object
.
0 of those orphans point to mail-disabled folders.

No folders need to be mail-disabled.

No orphaned MailPublicFolders were found.

No duplicate MailPublicFolders were found.

No mail-disabled public folders with proxy GUIDs were found.

No disconnected MailPublicFolders were found.

Done!
Write-Error: You cannot execute this script from your local Exchange server: "Ve
rsion 15.0 (Build 1497.2)". This script can only be executed from Exchange 2007
Management Shell and above.

The script then ends there - Looks to me that the script versions or when it gets to that line is incorrect or has incorrect line there.
So I myself attempt to- amend the version part by commenting out the script line the references the version - which seems to just overlook the version and continue.

Following from there, there was then an error with what seems to be an InvalidOpration Method invocation failed because [system.string] does not contact method named 'ToStringArray', here is the out put this is after me amending the Version/commenting out above that it gets to this point on the script run, also after connecting to EXO through the script as it attempt to sync the objects:

PS C:\Temp\PublicFolders> .\Sync-ModernMailPublicFolders.ps1 -CsvSummaryFile:syn
c_summary_test.csv -WhatIf
Checking for mail-enabled System folders...
Found 0 mail-enabled System folders.
Getting all public folders. This might take a while...
Found 907 public folders.
13 of those are mail-enabled.
0 folders are mail-enabled with no AD object.
13 folders are mail-enabled and are properly linked to an existing AD object.
Getting all MailPublicFolder objects...
0 MailPublicFolders are orphaned.
Building EntryId HashSets...
0 orphaned MailPublicFolder objects.
0 of those orphans point to mail-enabled folders that point to some other object
.
0 of those orphans point to mail-disabled folders.

No folders need to be mail-disabled.

No orphaned MailPublicFolders were found.

No duplicate MailPublicFolders were found.

No mail-disabled public folders with proxy GUIDs were found.

No disconnected MailPublicFolders were found.

Done!

Confirm
Are you sure you want to perform this action?
Performing the operation "Remove File" on target
"C:\Temp\PublicFolders\sync_summary_test.csv".
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help
(default is "Y"):Y
if (Version 15.0 (Build 1497.2).Major -ne 8 -and Version 15.0 (Build 1497.2).Maj
or -ne 14)
{
Write-Error (System.Collections.Hashtable.LocalServerVersionNotSupported -f
Version 15.0 (Build 1497.2)) -ErrorAction:Continue;
Exit;
}
[23/09/2022 11:00:02 AM] Creating an Exchange Online remote session...

----------------------------------------------------------------------------

The module allows access to all existing remote PowerShell (V1) cmdlets in addit
ion to the 9 new, faster, and more reliable cmdlets.

|--------------------------------------------------------------------------|
| Old Cmdlets | New/Reliable/Faster Cmdlets |
|--------------------------------------------------------------------------|
| Get-CASMailbox | Get-EXOCASMailbox |
| Get-Mailbox | Get-EXOMailbox |
| Get-MailboxFolderPermission | Get-EXOMailboxFolderPermission |
| Get-MailboxFolderStatistics | Get-EXOMailboxFolderStatistics |
| Get-MailboxPermission | Get-EXOMailboxPermission |
| Get-MailboxStatistics | Get-EXOMailboxStatistics |
| Get-MobileDeviceStatistics | Get-EXOMobileDeviceStatistics |
| Get-Recipient | Get-EXORecipient |
| Get-RecipientPermission | Get-EXORecipientPermission |
|--------------------------------------------------------------------------|

To get additional information, run: Get-Help Connect-ExchangeOnline or check htt
ps://aka.ms/exops-docs

Send your product improvement suggestions and feedback to exocmdletpreview@servi
ce.microsoft.com. For issues related to the module, contact Microsoft support. D
on't use the feedback alias for problems or support issues.

----------------------------------------------------------------------------

Using ConnectionUri:'https://outlook.office365.com/powerShell-liveID', in the en
vironment:'O365Default'.
[23/09/2022 11:00:54 AM] Exchange Online remote session created successfully.
[23/09/2022 11:00:54 AM] Enumerating local mail enabled public folders...
[23/09/2022 11:00:55 AM] Mail public folders enumeration completed: 13 local fol
der(s) found.
[23/09/2022 11:00:55 AM] Enumerating Exchange Online mail enabled public folders
...
[23/09/2022 11:00:56 AM] Mail public folders enumeration completed: 0 Exchange O
nline folder(s) found.

Sync local changes to Exchange Online
The following local mail public folder changes were detected and will be
applied to Exchange Online: 13 object(s) created, 0 updated and 0 deleted. Do
you really want to proceed?
[N] No [Y] Yes [?] Help (default is "N"): Y
Removed the PSSession ExchangeOnlineInternalSession_1 connected to outlook.offic
e365.com
Disconnected successfully !
InvalidOperation: C:\Temp\PublicFolders\Sync-ModernMailPublicFolders.ps1:209
Line |
209 | $emailAddressesArray = $localFolder.EmailAddresses.ToStringArray( .
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Method invocation failed because [System.String] does not contain a
| method named 'ToStringArray'.

Then it terminates the operation from there.

Unfortunately I am now stuck here, I tried to raise a support request within Office 365 but they advised me they do not know much of this script and that I should seek support from Microsoft on-prem Products instead for this issue. I feel like the script is poorly written for this and that perhaps it has been an after thought.

I am hoping someone out here has some more knowledge that myself to try work out what is going on with this script and why won't it proceed, it would be truly appreciated.

The script (which is mentioned in the Microsoft Documentation) can be found here: https://www.microsoft.com/en-us/download/details.aspx?id=54855
(its the Sync-ModernMailPublicFolders.ps1 and SyncModernMailPublicFolders.strings.psd1)

This is our On-prem 2013 Exchange Versions:
Name : EXCH01
Edition : Enterprise
AdminDisplayVersion : Version 15.0 (Build 1497.2)

Name : EXCH03
Edition : Enterprise
AdminDisplayVersion : Version 15.0 (Build 1497.2)

Name : EXCH02
Edition : Enterprise
AdminDisplayVersion : Version 15.0 (Build 1497.2)

Name : EXCH04
Edition : Enterprise
AdminDisplayVersion : Version 15.0 (Build 1497.2)

Regards,
David.

Exchange Server Development
Exchange Server Development
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Development: The process of researching, productizing, and refining new or existing technologies.
539 questions
Exchange Server Management
Exchange Server Management
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Management: The act or process of organizing, handling, directing or controlling something.
7,573 questions
Microsoft Exchange Hybrid Management
Microsoft Exchange Hybrid Management
Microsoft Exchange: Microsoft messaging and collaboration software.Hybrid Management: Organizing, handling, directing or controlling hybrid deployments.
2,055 questions
{count} votes

2 answers

Sort by: Most helpful
  1. KyleXu-MSFT 26,256 Reputation points
    2022-09-26T05:23:22.017+00:00

    @DamokMS

    Did you try to remove the “ToStringArray()”?

    I test it in may lab, there exist issue with it:

    244628-1.png

    After remove the “ToStringArray()”, this value still show in the array type:
    244672-2.png

    Do to this question related to script, it will help you add the "office-exchange-server-dev" tag to this thread.

    1 person found this answer helpful.

  2. Rory Carlin 0 Reputation points
    2023-08-24T10:20:32.5433333+00:00

    I also had the same problem and I was able to resolve it by upgrading the Exchange Server Management Tools on the computer that I was using to match the cumulative update version on the on-premises Exchange Server.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.