Managing automatic replies and out of office settings for a user
Exchange 2010 has introduced 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.
How to do it...
- 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 using the syntax shown next. For example, to disable Out of Office 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 use for the mailbox autoreply configuration:
Set-MailboxAutoReplyConfiguration dave ` -AutoReplyState Scheduled ` -StartTime 10/10/2011 ` -EndTime 10/15/2011 ` -ExternalMessage "I will be out of the office this week"
In this command, we set the AutoReplyState
, specify a StartTime
and EndTime
, and set the ExternalMessage
. When the StartTime
date is reached, the mailbox will proceed to automatically reply to messages using the specified ExternalMessage
until the EndTime
date is reached. If you want automatic replies to be enabled indefinitely, set the 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 see from viewing the mailbox auto-reply settings for this mailbox that only external replies are enabled. To enable internal Out of Office messages, you could 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 None
if no value is specified. The remaining options are Known
and All
. 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 when running reports. For example, to determine all of the users that currently have Out of Office 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
.