Setting Auto-Replies for Shared Mailboxes with PowerShell

Tell External People that the Company’s on Holiday

The question arose about the best way to set auto-replies 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.

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.

An auto reply message created with PowerShell
Figure 1: An auto reply message created with PowerShell

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:


For more information about working with shared mailboxes, see the chapter in the Office 365 for IT Pros eBook.

Advertisements

2 Replies to “Setting Auto-Replies for Shared Mailboxes with PowerShell”

  1. 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.

    1. 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.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.