
Managing automatic replies and Out of Office settings for a user
In Exchange 2010, we were introduced to a new set of cmdlets that can be used to manage and automate the configuration of a user's Out of Office settings. In this recipe, we'll take a look at how to use these cmdlets from the Exchange Management Shell for Exchange 2013.
How to do it...
Let's see how to manage automatic replies and Out of Office settings using the following steps:
- To view the Out of Office settings for a mailbox, use the following syntax:
Get-MailboxAutoReplyConfiguration dave
- You can change the Out of Office settings for a mailbox. For example, to disable the Out of Office settings for a mailbox, use the following command:
Set-MailboxAutoReplyConfiguration dave `-AutoReplyState Disabled
How it works...
Retrieving the settings for a mailbox simply requires that you run the Get-MailboxAutoReplyConfiguration
cmdlet and specify the identity of the mailbox, as shown in the previous example. The Set-MailboxAutoReplyConfiguration
cmdlet supports multiple parameters that can be used to customize the settings used for the mailbox autoreply configuration:
Set-MailboxAutoReplyConfiguration dave ` -AutoReplyState Scheduled ` -StartTime 1/26/2015 ` -EndTime 2/2/2015 ` -ExternalMessage "I will be out of the office this week"
In this command, we set AutoReplyState
, specify a StartTime
and EndTime
, and set ExternalMessage
. When the StartTime
date is reached, the mailbox will proceed to automatically reply to messages using the specified ExternalMessage
cmdlet until the EndTime
date is reached. If you want automatic replies to be enabled indefinitely, set AutoReplyState
to Enabled
.
To view the settings configured in the previous command, we can use the Get-MailboxAutoReplyConfiguration
cmdlet, as shown in the following screenshot:
You can notice that in the mailbox auto-reply settings for this mailbox, only external replies are enabled. To enable internal Out of Office messages, you can run the previous set command and specify a message using the –InternalMessage
parameter. Or, you can use them both using a single command.
The -InternalMessage
and -ExternalMessage
parameters support HTML-formatted messages. If you want to set custom HTML code when configuring the auto-reply configuration from the shell, you can use the following command syntax:
Set-MailboxAutoReplyConfiguration dave ` -ExternalMessage (Get-Content C:\oof.html)
This command will read in a custom HTML-formatted message from an external file and use that data when setting the internal or external message. This will allow you to work on the file from the HTML editor of your choice and import the code using a simple command from the shell.
By default, the -ExternalAudience
parameter will be set to All
if no value is specified. The remaining options are Known
and None
. Setting the external audience to Known
will only send automatic replies to external users who are listed as contacts in the users mailbox.
There's more...
These cmdlets can be useful when making mass updates and running reports. For example, to determine all of the users that currently have the Out of Office settings enabled, you can run the following command:
Get-Mailbox –ResultSize Unlimited | Get-MailboxAutoReplyConfiguration | ?{$_.AutoReplyState -ne "Disabled"} | Select Identity,AutoReplyState,StartTime,EndTime
This one-liner will check every mailbox in the organization and return only the mailboxes with the auto-reply state set to either Enabled
or Scheduled
.
Tip
Notice that the Out of Office configuration set by administrators will override any configuration done by the end user.