Quick answer: run Get-MailboxAutoReplyConfiguration -Identity tony@contoso.com to see a mailbox's Automatic Replies (out of office) settings. To check every mailbox, pipe Get-Mailbox -ResultSize Unlimited into it.
Get-MailboxAutoReplyConfiguration -Identity tony@contoso.com
The output shows:
AutoReplyState:Enabled,DisabledorScheduledStartTimeandEndTime: the window for a scheduled replyExternalAudience: who outside the organization gets a reply (None,KnownorAll)InternalMessageandExternalMessage: the reply text, stored as HTML
The cmdlet only reads settings. To change them, use Set-MailboxAutoReplyConfiguration.
Before you start
Connect. For Exchange Online, connect with the Exchange Online PowerShell module:
Connect-ExchangeOnline -UserPrincipalName admin@contoso.com
On Exchange Server 2010, 2013, 2016, 2019 or SE, open the Exchange Management Shell.
Permissions. You need permissions assigned before you can run the cmdlet, and some parameters may be missing if your role doesn't include them. Microsoft's Find the permissions required to run any Exchange cmdlet shows how to check which role you need.
Syntax
Get-MailboxAutoReplyConfiguration
[-Identity] <MailboxIdParameter>
[-Credential <PSCredential>]
[-DomainController <Fqdn>]
[-ReadFromDomainController]
[-ResultSize <Unlimited>]
[-UseCustomRouting]
[<CommonParameters>]
Parameters
| Parameter | What it does | Where |
|---|---|---|
-Identity |
The mailbox to check. Required, position 1, accepts pipeline input. Takes a name, alias, email address, UPN, GUID, DN, Domain\Username and similar values. |
All |
-Credential |
Runs the command as another account. Usually used with Get-Credential. |
All |
-DomainController |
The domain controller to read from, by FQDN, for example dc01.contoso.com. |
On-premises only |
-ReadFromDomainController |
Reads from the user's domain controller. Needed after Set-AdServerSettings -ViewEntireForest $true to include every object in the forest. |
All |
-ResultSize |
The maximum number of results. Use Unlimited for all. |
All |
-UseCustomRouting |
Listed for Exchange Online, but Microsoft doesn't document what it does. | Exchange Online |
Careful with -Identity: Microsoft warns that a $null or non-existent value returns every mailbox. If you build the identity from a variable, check the variable first.
What the settings mean
These values come from the matching parameters on Set-MailboxAutoReplyConfiguration.
| Property | Values |
|---|---|
AutoReplyState |
Enabled: replies are sent. Disabled: no replies (default). Scheduled: replies are sent only between StartTime and EndTime. |
ExternalAudience |
None: no external replies. Known: only senders in the mailbox's contacts. All: every external sender (default). |
StartTime, EndTime |
Only matter when AutoReplyState is Scheduled. |
InternalMessage |
Sent to senders inside the organization when replies are on. |
ExternalMessage |
Sent to outside senders when replies are on and ExternalAudience is Known or All. |
Exchange wraps plain message text in HTML tags, so expect <html><body>...</body></html> in the output.
Examples
Check one mailbox
Get-MailboxAutoReplyConfiguration -Identity tony@contoso.com |
Format-List AutoReplyState, StartTime, EndTime, ExternalAudience
Check a shared mailbox
Shared mailboxes use the same command. Pass the shared mailbox's address:
Get-MailboxAutoReplyConfiguration -Identity support@contoso.com
List every mailbox with replies on
This is Microsoft's all-mailboxes example with a filter added:
Get-Mailbox -ResultSize Unlimited |
Get-MailboxAutoReplyConfiguration |
Where-Object { $_.AutoReplyState -ne 'Disabled' } |
Select-Object Identity, AutoReplyState, StartTime, EndTime, ExternalAudience
Find scheduled replies that already ended
Get-Mailbox -ResultSize Unlimited |
Get-MailboxAutoReplyConfiguration |
Where-Object { $_.AutoReplyState -eq 'Scheduled' -and $_.EndTime -lt (Get-Date) } |
Select-Object Identity, StartTime, EndTime
Export a report to CSV
Get-Mailbox -ResultSize Unlimited |
Get-MailboxAutoReplyConfiguration |
Select-Object Identity, AutoReplyState, StartTime, EndTime, ExternalAudience, InternalMessage, ExternalMessage |
Export-Csv -Path C:\Reports\AutoReplies.csv -NoTypeInformation
Read the reply text
$config = Get-MailboxAutoReplyConfiguration -Identity tony@contoso.com
$config.InternalMessage
$config.ExternalMessage
Use a canonical name on-premises
Microsoft's second example identifies the mailbox by its Active Directory path:
Get-MailboxAutoReplyConfiguration -Identity 'contoso.com/Users/Tony Smith'
Troubleshooting
A not-found error. The identity doesn't match a mailbox. Try the primary SMTP address, or run Get-Mailbox -Identity <value> to confirm it exists.
The command returns every mailbox. The identity was $null or didn't exist. Check the variable you passed.
-DomainController isn't recognized. It only exists on-premises. Drop it in Exchange Online.
The term isn't recognized as a cmdlet. You're not connected. Run Connect-ExchangeOnline or open the Exchange Management Shell.
A parameter is missing. Your role doesn't include it. Check the role with Microsoft's permissions guide linked above.
The state says Scheduled but no replies go out. The current time is outside StartTime and EndTime. Compare both with Get-Date.
FAQ
How do I check if out of office is on for a user?
Run Get-MailboxAutoReplyConfiguration -Identity user@contoso.com and read AutoReplyState. Enabled means on, Scheduled means on between the start and end times, and Disabled means off.
How do I turn out of office on or off with PowerShell?
Use Set-MailboxAutoReplyConfiguration. For example, Microsoft's own example turns replies on for internal and all external senders:
Set-MailboxAutoReplyConfiguration -Identity tony@contoso.com -AutoReplyState Enabled -InternalMessage "Internal auto-reply message." -ExternalMessage "External auto-reply message." -ExternalAudience All
To turn them off, set -AutoReplyState Disabled.
Can users set this themselves?
Yes. Users can set automatic replies in Outlook. See how to set out of office in Outlook.
Does it work in Exchange Online and on-premises?
Yes. Microsoft lists it for Exchange Server 2010, 2013, 2016, 2019, Exchange Server SE and Exchange Online. -DomainController is on-premises only and -UseCustomRouting is Exchange Online only.
How do I find a mailbox's identity?
Run Get-Mailbox and use the PrimarySmtpAddress or Alias it returns.
Sources: Get-MailboxAutoReplyConfiguration, Set-MailboxAutoReplyConfiguration and Find the permissions required to run any Exchange cmdlet on Microsoft Learn.
Managing Microsoft 365 rooms too? Meeting Room 365 turns any tablet into a room display for Outlook and Teams calendars.