Skip to content

/commands/exchange-online/set-mailboxautoreplyconfiguration

Set-MailboxAutoReplyConfiguration: set an out-of-office reply for another mailbox

The commands on this page have not been executed by our verification runner yet.updated
tool
Exchange Online PowerShell
versions
Exchange Online, Exchange Server 2016+, ExchangeOnlineManagement 3.x
os
windows, linux, macos

An administrator can turn on Automatic Replies (out of office) for any mailbox with Set-MailboxAutoReplyConfiguration, without signing in as the user:

powershell
Set-MailboxAutoReplyConfiguration -Identity tony@contoso.com -AutoReplyState Enabled `
  -InternalMessage "I'm out of the office until Monday." `
  -ExternalMessage "I'm out of the office until Monday. For urgent matters contact help@contoso.com." `
  -ExternalAudience All

Connect with Connect-ExchangeOnline first. To turn it off again: Set-MailboxAutoReplyConfiguration -Identity tony@contoso.com -AutoReplyState Disabled.

Scheduled replies

powershell
Set-MailboxAutoReplyConfiguration -Identity tony@contoso.com -AutoReplyState Scheduled `
  -StartTime "07/10/2026 08:00" -EndTime "07/15/2026 17:00" `
  -InternalMessage "Internal auto-reply message"

-StartTime and -EndTime use the short date format of the computer running the command (MM/dd/yyyy on en-US); quote values that include a time. They are used only when -AutoReplyState is Scheduled.

Parameters

ParameterValues
-AutoReplyStateEnabled, Disabled (default), Scheduled
-InternalMessageText for senders inside the organization; HTML tags are added automatically
-ExternalMessageText for external senders; used when ExternalAudience is Known or All
-ExternalAudienceNone, Known (senders in the mailbox contacts), All (default)
-CreateOOFEvent / -OOFEventSubject$true creates a calendar event for the scheduled period (cloud only)
-AutoDeclineFutureRequestsWhenOOF$true declines new meeting requests during the scheduled period (cloud only)
-DeclineEventsForScheduledOOF / -DeclineAllEventsForScheduledOOFDecline existing meetings in the period (cloud only)

Check the current setting

powershell
Get-MailboxAutoReplyConfiguration -Identity tony@contoso.com |
  Format-List AutoReplyState,StartTime,EndTime,ExternalAudience,InternalMessage,ExternalMessage

The messages are stored as HTML: "I'm on vacation" becomes <html><body>I'm on vacation</body></html>. You can pass your own HTML in the value to format the reply.

When to use it

Administrators set automatic replies with PowerShell when the user cannot do it: an unplanned absence, a leaver whose mailbox is being converted to a shared mailbox, or a team mailbox that should announce a holiday closure. It is also the fastest way to apply the same message to many mailboxes at once, for example by piping addresses from a CSV file into a ForEach-Object loop. For a leaver, combine it with forwarding or with converting the mailbox to shared.

Requirements

The cmdlet is not part of the ExchangeOnlineManagement module itself: it is created by Connect-ExchangeOnline, so it fails as "not recognized" before you connect or when your roles do not include it. To change other people's mailboxes you need an Exchange role that covers recipient settings, such as the Recipient Management or Organization Management role group. Both Windows PowerShell 5.1 and PowerShell 7 work with ExchangeOnlineManagement 3.x.

Pitfalls

  • Scheduled versus Enabled. Scheduled turns the reply on and off by itself at -StartTime and -EndTime; Enabled stays on until someone sets Disabled, so prefer Scheduled when the return date is known.
  • Date format. The start and end times are parsed with the regional format of the computer running the command, so 07/10/2026 means 10 July on en-US but 7 October on many European settings. Use an unambiguous form or build the value with Get-Date.
  • External audience. The default sends the external message to everyone, which may include mailing lists and spam senders; Known limits it to contacts.

Errors you may see

MessageMeaning
The term 'Set-MailboxAutoReplyConfiguration' is not recognizedNot connected yet, or your roles do not include the cmdlet
The operation couldn't be performed because object '...' couldn't be foundThe -Identity value does not match a mailbox

See Get-Mailbox is not recognized and object couldn't be found for the fixes.

FAQ

Does the user see the reply in Outlook after I set it with PowerShell?

Yes. The cmdlet changes the same Automatic Replies setting that Outlook and Outlook on the web show, so the user can edit or turn it off there afterwards.

Can I set an out-of-office reply for a shared mailbox?

Yes. Pass the shared mailbox address to -Identity; shared mailboxes use the same automatic reply settings as user mailboxes.

Why is the reply not sent to external senders?

Check -ExternalAudience. None sends no external reply, and Known replies only to senders in the mailbox's contacts. Use All to reply to every external sender.

Sources