/commands/exchange-online/set-mailboxautoreplyconfiguration
Set-MailboxAutoReplyConfiguration: set an out-of-office reply for another mailbox
- 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:
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 AllConnect with Connect-ExchangeOnline first. To turn it off again: Set-MailboxAutoReplyConfiguration -Identity tony@contoso.com -AutoReplyState Disabled.
Scheduled replies
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
| Parameter | Values |
|---|---|
| -AutoReplyState | Enabled, Disabled (default), Scheduled |
| -InternalMessage | Text for senders inside the organization; HTML tags are added automatically |
| -ExternalMessage | Text for external senders; used when ExternalAudience is Known or All |
| -ExternalAudience | None, 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 / -DeclineAllEventsForScheduledOOF | Decline existing meetings in the period (cloud only) |
Check the current setting
Get-MailboxAutoReplyConfiguration -Identity tony@contoso.com |
Format-List AutoReplyState,StartTime,EndTime,ExternalAudience,InternalMessage,ExternalMessageThe 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.
Scheduledturns the reply on and off by itself at-StartTimeand-EndTime;Enabledstays on until someone setsDisabled, so preferScheduledwhen 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/2026means 10 July on en-US but 7 October on many European settings. Use an unambiguous form or build the value withGet-Date. - External audience. The default sends the external message to everyone, which may include mailing lists and spam senders;
Knownlimits it to contacts.
Errors you may see
| Message | Meaning |
|---|---|
| The term 'Set-MailboxAutoReplyConfiguration' is not recognized | Not connected yet, or your roles do not include the cmdlet |
| The operation couldn't be performed because object '...' couldn't be found | The -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.