Use this script with modern public folders only. See this post for legacy public folders.
When you want to migrate your modern public folders from Exchange 2013 or newer to modern public folders in Exchange Online, you must prepare the public folder names for migration.
Public folder names are not allowed to contain the following:
- A backslash “\”
- A forward slash “”/””
- A semicolon “”;””
- A comma “”