If you have an Exchange mailbox, you have the option to configure Out of Office messages when you are away from work:
Usually, the default options is sufficient: You configure a message, a time range, and you are all set.
In my scenario, I am having a paternity leave for the next 20 weeks where I will work 50% during the work week. This means I will have to turn Out of Office on and off several times every week.
This is a perfect opportunity to look into what options we have as end users when working with PowerShell against Exchange - whether it is Exchange Online or an on-premises such as Exchange Server 2016.
The article Connect to Exchange Online PowerShell outlines the necessary steps. Let us try this using a regular user with no administrative permissions and see which commands we have access to:
That is quite a lot of commands, and many of them can be very useful. For example, we can change our photo using Get/Set-UserPhoto as well as view and clean up mobile devices using Get/Set-MobileDevice.
What we are looking for is Set-MailboxAutoReplyConfiguration, which can perform the task we want to automate:
We can also verify the result:
The last piece of the puzzle is to schedule this script to run on the desired days of week.
One option is to run it as a scheduled task on a local computer, but I have chosen to run it in Azure Automation in order to avoid relying on a computer being powered on. You can get an Azure Automation account with up to 500 minutes of runbook run time each month, which should cover the needs in this example.
The runbook can then the attached to a custom schedule in order to make it run on the week days we want:
In this article we have looked at how to automate the configuration of Out of Office scheduling for an Exchange mailbox using PowerShell and Azure Automation.
I am also using an Azure Automation runbook with the opposite schedule as for the Out of Office scheduling runbook for starting the climate control in my car. More details about that is available in a previous article - Manage Tesla climate control system using PowerShell.