Tell External People that the Company’s on Holiday
The question arose about the best way to set the auto-reply on shared mailboxes to inform external senders that the company is on holiday (public or otherwise). Some suggested using Flow for the job. I, of course, thought of PowerShell. I’m not against Flow: I simply think that PowerShell offers more control and flexibility, especially when multiple shared mailboxes are involved.
Auto-replies, or OOF (Out of Facility) notifications as they are known in the trade, go back to the dawn of email (before Exchange 4.0). It’s easy to set auto-replies with PowerShell using the Set-MailboxAutoReplyConfiguration cmdlet. The Get-MailboxAutoReplyConfiguration cmdlet reports the current auto-reply state of a mailbox.
A New Auto-Reply for Shared Mailboxes
The example solution uses a quick and dirty script to find all shared mailboxes in the tenant and set two auto-replies. One (brief) for internal correspondents; the other (less terse and nicer) for external people. Two variables are declared to set the start and end time for the scheduled auto-reply. If you specify a time, remember that Exchange Online runs on UTC so any time you set is in UTC. In other words, convert your local time to UTC when you set up the auto-reply. Rather bizarrely, Get-MailboxAutoReplyConfiguration converts the UTC time to local (workstation) time when it reports an auto-reply configuration.
#These times are in UTC $HolidayStart = "04-Aug-2019 17:00" $HolidayEnd = "6-Aug-2019 09:00" $InternalMessage = "Expect delays in answering messages to this mailbox due to the holiday between <b>" + $HolidayStart + "</b> and <b>" + $HolidayEnd + "</b>" $ExternalMessage = "Thank you for your email. Your communication is important to us, but please be aware that some delay will occur in answering messages to this mailbox due to the public holiday between <b>" + $HolidayStart + "</b> and <b>" + $HolidayEnd + "</b>" $Mbx = (Get-Mailbox -RecipientTypeDetails SharedMailbox | Select DisplayName, Alias, DistinguishedName) ForEach ($M in $Mbx) { # Set auto reply Write-Host "Setting auto-reply for shared mailbox:" $M.DisplayName Set-MailboxAutoReplyConfiguration -Identity $M.DistinguishedName -StartTime $HolidayStart -AutoReplyState "Scheduled" -EndTime $HolidayEnd -InternalMessage $InternalMessage –ExternalMessage $ExternalMessage -ExternalAudience 'All' -CreateOOFEvent:$True }
Figure 1 shows the result when an external person sends email to a shared mailbox. You can be as creative as you like with the text.

Removing Auto-Replies
The scheduled auto-reply lapses when the end time arrives. If you want to remove auto-replies from all shared mailboxes, run the command:
# We assume that all shared mailboxes are in $Mbx ForEach ($M in $Mbx) { Set-MailboxAutoReplyConfiguration -Identity $M.DistinguishedName -AutoReplyState "Disabled" }
For more information about working with shared mailboxes, see the chapter in the Office 365 for IT Pros eBook.
Hello, does it work with regular mailboxes without sharing option?. How can I configure a .txt file with a list of users I want to set the MailboxAutoReply. Something like this would work?
$Mbx = (C:\mailboxList.txt Get-Content | Select DisplayName, Alias, DistinguishedName)
ForEach ($M in $Mbx)
…
If it is possible i just need to know how to build the txt file.
I would use a CSV file (because you get named columns) and read the information in from it instead of a text file. After that, it’s just a matter of updating each mailbox with the autoreply information.
Is there a way I can set Auto Replied by using Inputs, like username, duration and message?
Sure. You can do this with PowerShell. Check out Set-MailboxAutoReplyConfiguration.
There exists a tool named CentralOOF (https://ivasoft.com/centraloof.shtml)
that allows an Office 365 admin to toggle the status (disabled/enabled/scheduled) and modify parameters of Out of Office auto-replies for Office 365 mailboxes.