Back to Blog

Public Folder Scripts and Basic Authentication

Image of Jaap Wesselius
Jaap Wesselius
Microsoft Exchange Updates

By now you must be aware that Microsoft will turn off basic authentication in Office 365 later this year and that will hit Exchange Online severely. It’s not a big deal when it comes to mail clients or the administrator console (EAC), but automation using PowerShell scripts will be impacted and I recently ran into such an issue.

If you have an Exchange hybrid environment and are using Public Folders, (some of) your Mailboxes are in Exchange Online, but your Public Folders are still on-premises. For this to work properly, your Public Folder Mailboxes must be synchronized using Azure AD Connect, and you must run a PowerShell script (called Sync-ModernMailPublicFolders.ps1) to synchronize the mail-enabled Public Folders with Exchange Online.

This works fine, until Basic Authentication is turned off and an error is shown:


Or in plain text:

Unable to create a remote shell session to Exchange Online. The error is as follows: "Connecting to remote server failed with the following error message: Access is denied

You won’t notice this error immediately, but at some point you will notice that changes in Public Folders are not visible in Outlook anymore.

The not recommended solution is to re-enable basic authentication, but you can also download the updated script from Microsoft that support modern authentication as of May 2022. You can find the updated Public Folder migration scripts on the Microsoft site.

Note: Another pitfall here is conditional access enforcing MFA, I ran into this as well at a customer, resulting in the same error message.



With email being one of the most mission-critical tools for organizations today, how do you ensure vital business communication stays up and running? How do you demonstrate to senior management that additional resources are needed to meet growing demand or that service levels are being met?

Developed by Exchange architects with direct product input from Exchange MVPs, ENow's Mailscape makes your job easier by putting everything you need into a single, concise OneLook dashboard, instead of forcing you to use fragmented and complicated tools for monitoring and reporting. Easy to deploy and intuitive to use, get started with Mailscape in minutes rather than days.

ACCESS YOUR FREE 14-DAY TRIAL and combine all key elements for your Exchange monitoring and reporting to keep your messaging infrastructure up and running like a pro!


  • Consolidated dashboard view of messaging environments health
  • Automatically verify external Mail flow, OWA, ActiveSync, Outlook Anywhere
  • Mail flow queue monitoring
  • DAG configuration and failover monitoring
  • Microsoft Security Patch verification
  • 200+ built-in, customizable reports, including: Mailbox size, Mail Traffic, Quota, Storage, Distribution Lists, Public Folders, Database size, OWA, Outlook version, permissions, SLA and mobile device reports

Access Free 14-Day Trial

Basic Authentication banner image

The End of Basic Authentication – Will It Hurt You?

Image of Jaap Wesselius
Jaap Wesselius

Microsoft will stop support for basic authentication in Office 365 starting October 1, 2022. Uhm,...

Read more
Last Exchange Server listing image

The Last Exchange Server

Image of Michel de Rooij
Michel de Rooij

In the announcement that was part of the release of the most recent set of Cumulative Updates for...

Read more