Migrating Archiving from Microsoft Exchange Server to Microsoft 365
In this article, the changes required in MailStore Server when migrating the e-mail environment from a local Microsoft Exchange installation to Microsoft 365 are shown. Our Technical Tip video provides a general overview. Please note that the actual steps may differ from those shown in the video, depending on your current configuration.

Technical Tip: Changing Archiving from Microsoft Exchange Server to Microsoft 365
Notes and Things to Consider
Any change in a production environment, including changing archiving in MailStore Server, should be carefully planned in advance. Therefore, before applying any changes, please consider the following notes:
- It is strongly recommended that the changes described in this article be applied first in a test environment, because changes to your Exchange and MailStore Server installations may not be easily rolled back without significant effort.
- Before applying any changes to your production environment, please ensure that you have up-to-date backups of your Exchange and MailStore Server installations. For Service Provider Edition, see this Backup article.
- It is recommended that you update MailStore Server to the latest version before making any changes. Please ensure that your Update and Support Service Agreement is valid (not related to Service Provider Edition) and consider update notifications (MailStore Server) / update notifications (Service Provider Edition).
- It is assumed that MailStore Server currently operates in an Active Directory / Exchange Server environment according to the MailStore Application Guide for Microsoft Exchange Servers and will subsequently operate according to the MailStore Application Guide for Microsoft 365 (Modern Authentication).
- Changes in MailStore Server configuration should be applied in Safe Mode to prevent mixing of background tasks or user interactions. For Service Provider Edition, see the "Safe Mode" section in the Management Console.
- Disable all scheduled tasks in Windows Task Scheduler that perform directory service synchronization, trigger archiving, or otherwise interact with the archive.
- Microsoft 365 does not support hosted daily mailboxes within Microsoft 365. If you archive all incoming and outgoing emails with MailStore Server, you will need a hosted daily mailbox outside of Microsoft 365. MailStore offers the MailStore Gateway as a free solution within your company's intranet to provide daily mailboxes.
Changing User Synchronization
As a first step, you should change the directory services that MailStore Server uses to synchronize users from Active Directory to Microsoft 365 (Modern Authentication). This is required because Microsoft 365 uses Azure Active Directory as the directory service instead of the local Active Directory.
Initially, please run a directory services synchronization with the existing configuration on MailStore Server to ensure that all user data is complete and up-to-date.
User Name Format
The steps required to change the directory service are dependent on the user name format used by MailStore Server for user synchronization with the local Active Directory.
- If you are currently using SAM Account Name or User Principal Name (Local Part), i.e., a "flat" user name without the domain part as the user name on MailStore Server (e.g., john.doe), then users and archive folders must be renamed on MailStore Server. In this case, please follow the steps in the next section.
- If you are already using the full User Principal Name (UPN, e.g., john.doe@example.com) as the user name on MailStore Server and this will be used to log in to Microsoft 365 in the future, you can leave the user names, archive folders, and source folders as they are. Please proceed directly to the section "Changing Directory Service Synchronization to Microsoft 365."
- If you want to change the naming convention of the UPN for logging in to Microsoft 365 (e.g., from john.doe@example.com to jdoe@example.com or jane.doe@example.com to jane.doe@example.org), the user names, archive folders, and source folders on MailStore Server need to be renamed. In this case, please follow the steps in the next section.
MailStore Migration Scripts
The changes described in the following sections are based on Windows PowerShell 3.0 or higher.
- You can download the scripts for MailStore Server from here; they can be found in the folder after extraction. For Service Provider Edition, please use these scripts instead.
- To use the scripts with MailStore Server, enable access to the MailStore Management API in the MailStore Server Service Configuration.
- For Service Provider Edition, enable provider access for the relevant instance.
Renaming Users and Archives on MailStore Server
MailStore Server distinguishes users only by their user name. For example, from the perspective of a MailStore Server requiring two licenses, two different users are considered. Furthermore, a user's archive is only associated with their user name, so MailStore will always create an archive named (Archive) john.doe for a user named john.doe. However, if such an archive contains archived emails, it will retain its name even if the associated user name changes. john.doe john.doe@example.com john.doe
For these reasons, the user names and archive folders on MailStore Server must match the user names of the directory service that MailStore Server synchronizes its users with. Since Azure Active Directory uses the full User Principal Name (UPN, usually the primary email address) as the user name, you must rename users and archive folders if you are currently using a different user name format or wish to change the UPN.
To rename users and archive folders, please do the following (for Service Provider Edition, files have the SPE_ prefix, but behave similarly):
- Edit the scripts and set values in the section "Setting Values According to Your MailStore Server Installation" in PowerShell ISE. MSS_1_prepare_users.ps1 MSS_2_update_users.ps1
- Run the script in PowerShell ISE by pressing F5. MSS_1_prepare_users.ps1
- A file is created (by default in the folder). It contains current MailStore Server user names. mailstore-users.txt C:\Users\
- Edit this file in a text editor and change the new user names after the '=' sign so that entries appear as follows: AD user name=Microsoft 365 user name Example (highlighted changes) jane.doe=jane.doe@example.com Please use only lowercase letters for the user names. For user names that should not change (e.g., the default administrator user), leave the respective entries as they are.
- Save the file containing both current and future user names. mailstore-users.txt
- Run the script in PowerShell ISE by pressing F5. MSS_2_update_users.ps1
- The script now renames users and archive folders in MailStore Server and updates the folder permissions accordingly.
- Log on to MailStore Server as a MailStore Administrator using the MailStore Client and check the new user names and archive folders.
- If the local part of the email addresses ("@") has not changed, you can proceed directly to the steps in the section "Changing Directory Service Synchronization to Microsoft 365." Otherwise, the source folders may need to be renamed as described in the next section.
Renaming Source Folders on MailStore Server
The folder level under archive folders reflects the source that MailStore Server archives emails for. In Exchange archiving, the folder name consists of the Exchange prefix and the local part of the email address ("@" before part), so that the source folder name for an email address in MailStore Server would be Exchange john.doe@example.com. john.doe@example.com
The source folder names must be renamed only if all of the following conditions and requirements are met. Otherwise, you can proceed directly with the steps in the section "Changing Directory Service Synchronization to Microsoft 365."
- The local part of the email address will be changed during the transition to Microsoft 365 (e.g., john.doe@example.com to j.doe@example.com)
- Both the emails archived so far from the local Exchange Server and the emails to be archived in the future from Microsoft 365 should appear with the same folder structure at the source level (e.g., Exchange john.doe and Exchange j.doe).
To rename source folders, please do the following:
-
Enable access to user archives by administrators on MailStore Server; it is disabled by default. Changing this option is explained in the "Compatibility General" section of the MailStore Server guide.
-
Edit the scripts and set values in the section "Setting Values According to Your MailStore Server Installation" in PowerShell ISE. MSS_3_prepare_folders.ps1 MSS_4_update_folders.ps1
-
Run the script in PowerShell ISE by pressing F5. MSS_3_prepare_folders.ps1
-
A file is created (by default in the folder). It contains full paths of source folders separated by "/," consisting of user names and source folder names. mailstore-folders.txt C:\Users\
-
Edit this file in a text editor and change the new source folders after the '=' sign so that entries appear as follows: Old source folder path=new source folder path Example (highlighted changes) j.doe@example.com/Exchange jane.doe=j.doe@example.com/Exchange j.doe For source folders that should not change, leave the respective entries as they are.
-
Save the file containing both current and future source folders. mailstore-folders.txt
-
Run the script in PowerShell ISE by pressing F5. MSS_4_update_folders.ps1
-
The script now renames source folders in MailStore Server.
-
Log on to MailStore Server as a MailStore Administrator using the MailStore Client and check the new source folders.
Changing Directory Service Synchronization to Microsoft 365
To allow users to log in to MailStore Server with Microsoft 365 credentials instead of Active Directory, you must change the directory service synchronization to Microsoft 365 (Modern Authentication). Please follow the steps in the section "Synchronizing User Accounts with Microsoft 365 (Modern Authentication)" in the MailStore Server guide. Initially, use the Test Settings button to test the synchronization. Check the directory service synchronization results; the migrated users should be shown as changed. You can also check if user authentication against Microsoft 365 works as expected.
Changing Archiving Profiles
MailStore Server offers special Microsoft 365 archiving profiles that support modern authentication for archiving Microsoft 365 mailboxes. Existing Exchange archiving profiles, which only support basic authentication, cannot be used for archiving Microsoft 365 mailboxes.
Disabling Existing Profiles and Jobs
If you run MailStore Server as previously recommended in Safe Mode, archiving profiles and jobs are automatically disabled (Service Provider Edition: Management Console, Safe Mode). To disable them permanently, please proceed as follows:
- Log on to MailStore Server as a MailStore Administrator via the MailStore Client.
- Click Email Archive.
- Enable the option Show All Users' Profiles under the profiles list.
- From the context menu, change each Exchange archiving profile to Manual.
- If you have configured Exchange export profiles, click Email Export in the menu tree and repeat the previous steps.
- If you have scheduled jobs to run Exchange profiles, click Jobs > Administration Tools > Administration API and disable each job from the context menu that runs an Exchange profile.
Creating New Microsoft 365 Profiles
Create new Microsoft 365 profiles and jobs according to the following articles. They should be set up manually at first to check their execution and results.
- Follow the Email Archiving from Microsoft 365 (Modern Authentication) application guide to archive Microsoft 365 mailboxes.
- Creating Microsoft 365 export profiles is described in the Email Export section of the MailStore Server guide.
- After the profiles are set, you can update existing jobs according to the Jobs section of the MailStore Server guide.
Finalizing the Migration
To complete the migration on MailStore Server, please perform the following steps:
- Close all MailStore Client sessions and restart the MailStore Server service.
- Log on to MailStore Server as a MailStore Administrator via the MailStore Client again.
- Go to Users and Archives > Archives > Administrative Tools in the main menu tree and check the archive folder names.
- Go to Email Archive and manually run each Microsoft 365 archiving profile. If you are satisfied with the results, you can delete the old Exchange archiving profiles.
- If possible, repeat the previous step to export the profiles and jobs.
- If you have enabled administrator access to user archives on MailStore Server as described in the Compatibility General section earlier, revert this change.
- If you have enabled Single Sign-On (SSO) by setting the server name and authentication method on MailStore Server via Group Policy for the MailStore Client or MailStore Outlook Add-in to Windows Authentication, you need to change the Group Policy setting for authentication to Standard Authentication.
- During login, the MailStore Web Access, MailStore Clients, and Outlook Add-in call the default web browser to allow the user to log in via the Microsoft 365 login dialog; this communication is encrypted with TLS over HTTPS. Therefore, it is recommended to configure a trusted SSL certificate on MailStore Server for a better user experience. For more information, see the article Using Your Own SSL Certificate (Service Provider Edition: Replace Self-Signed SSL Certificates).
After successfully completing these tasks, the migration is complete on MailStore Server.
Source: Changing Archiving from Microsoft Exchange Server to Microsoft 365 - MailStore Server Help