Restore Out of Office state after Hybrid Migration

In the last couple of years in Exchange Online support, me and my colleagues from EMEA Office 365 Exchange Escalations Team discovered a few cases when Out of Office behavior became corrupt if was set before Hybrid Migration from Exchange on-prem servers to Exchange Online. To help customers, that encounter this type of issue, I wrote a script that provides a solution.

After a Hybrid Migration to Office 365 it is possible that Out of Office messages not to work as expected. The following type of issues can occur if Out of Office was set before mailbox migration:
– Out of Office (OOF) message is sent back more than once to the same sender;
– Out of Office was scheduled for a period of time and these OOF messages are still sent after Out of Office EndTime passed;

The script will tickle Out of Office  settings. This will solve above issues.
The script is published in Microsoft’s TechNet Gallery:

Script description:
– read the script’s parameters from the command line (if any);
– if the Administrator is not providing any credentials while trying to connect to Exchange  Online remote PowerShell session, the script will prompt the admin to input them and will attempt to connect;
– if the CSV output file name and path is not provided, the script will create one:
$CSV_file_path = “C:\Temp\ExoVoice\”
$OOF_CSV_File = “C:\Temp\ExoVoice\OOF_MyCsvFile.csv”
– check if CSV file already exists, this means that the script was run before;
– if the CSV file does not exist, we will read the mailboxes, toggle OOF status, and output data in CSV file;
– if the mailbox does not have an UserPrincipalName, the script will inform you (in CSV file and on screen) that you have an orphan mailbox. You should take care of this issue separately;
– if the CSV file already exists, we will compare mailbox list with CSV content and will toggle only mailboxes not present in the CSV file (newly migrated mailboxes);
– because of the above features, you are protected in case the script execution is interrupted abruptly, or in case you have a large number of mailboxes (tens of thousands) and you do not want to let the script process all mailboxes. At each run, the script will compare the list of mailboxes from CSV file and the list of mailboxes present in tenant. This feature is also handy if you have a large number of mailboxes in on-prem and you migrate the mailboxes to the cloud in batches. Also, you are able to open the CSV file and delete the rows with the mailboxes that you want to be processed again.

Script parameters:
O365Admin -> Administrator login ID
O365AdminPassword -> Administrator login password
CSV_file_path -> The file path where you want to output the OOF CSV file.

To run the script, please use the following format:
.\Restore_OOF_state_after_Hybrid_Migration.ps1 [-O365Admin ] [-O365AdminPassword ] [-CSV_file_path ]

Samples of how you should run the script:

With full set of parameters:
.\Restore_OOF_state_after_Hybrid_Migration.ps1 -O365Admin -O365AdminPassword Password123 -CSV_file_path “C:\Temp\ExoVoice\”

With no parameters:

NOTE1: Before using the script, please read the Microsoft Disclaimer:
The sample scripts are not supported under any Microsoft standard support program or service. The sample scripts are provided AS IS without  warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.
NOTE2: This script can be easily modified to store also the OOF message in the CSV file. If you want to do this, you can easily edit the CSV file and modify the OOF message for all mailboxes in the tenant.
In this way you will be able to easily edit the OOF messages for everybody and make them compliance to your company’s rules.


Comments (0)

Skip to main content