Wednesday, 20 December 2017

Set Auto Reply on a Mailbox in Office 365 using PowerShell

In this post I am going to share how to configure automatic reply or out-of-office message on a user's mailbox. We can use the Set-MailboxAutoReplyConfiguration cmdlet to configure automatic reply settings for a specific user mailbox and this cmdlet is available for both Exchange On-Premises and Exchange Online environment.

Before proceed, first we need to connect Exchange Online powershel module by running below commands:
$o365Cred = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri -Credential $o365Cred -Authentication Basic -AllowRedirection
Import-PSSession $Session


Set Automatic Reply for user's mailbox :

The below command configures Automatic Reply message to be sent on AlexW's mailbox.
Set-MailboxAutoReplyConfiguration -Identity "AlexW" -AutoReplyState Enabled -InternalMessage "Out of Office message for internal mails." -ExternalMessage "Out of Office message for external mails."
Once you run the above command the mailbox of AlexW will instantly start to send automatic reply for all incoming mails, instead if you want to send out of office message only for particular days, you need to set parameter -AutoReplyState as "Scheduled".

Set Automatic Reply in a specific time period :

If you want to configure to send auto reply message in a particular days like office holidays or when employees on leave, you need to set parameter -AutoReplyState as "Scheduled" along with "StartTime" and "EndTime".
Set-MailboxAutoReplyConfiguration -Identity "AlexW" -AutoReplyState Scheduled -StartTime "07/10/2018 01:00:00" -EndTime "7/15/2018 23:00:00" -InternalMessage "Internal out-of-office message"
Note: The parameters StartTime and EndTime are meaningful only when AutoReplyState is Scheduled. To set value for these two parameter, you need to use the short date format that's defined in the Regional Options settings on the computer where you're running the command.

Disable or Stop Auto Reply message :

Run the below command to disable or stop the out of office message.
Set-MailboxAutoReplyConfiguration -Identity "AlexW" -AutoReplyState Disabled
Run the below command if you want to clear or remove Internal/External message when you stop auto reply.
Set-MailboxAutoReplyConfiguration -Identity "AlexW" -AutoReplyState Disabled -InternalMessage "" -ExternalMessage ""

Disable Auto Reply message for External senders :

The Set-MailboxAutoReplyConfiguration cmdlet includes the parameter ExternalAudience, it specifies whether Automatic Replies are sent to external senders or not.

Valid values for ExternalAudience:
  • None - Don't sent message to any external senders.
  • Known - Send only to external senders that are specified in the Contact list of the mailbox.
  • All - Send to all external senders. This is the default value
 The below command enables auto reply for only internal senders by setting ExternalAudience value as "None".
Set-MailboxAutoReplyConfiguration -Identity "AlexW" -ExternalAudience "None" -AutoReplyState Scheduled -StartTime "07/10/2018 01:00:00" -EndTime "7/15/2018 23:00:00" -InternalMessage "Internal auto-reply message"

Get Automatic Reply Configuration :

Once you have configured the automatic reply settings you can get the latest setting by running below command.
Get-MailboxAutoReplyConfiguration -Identity "AlexW"
Run the below command if you want to get settings for all the mailbox users.
Get-Mailbox -ResultSize unlimited | Get-MailboxAutoReplyConfiguration


No comments:

Post a Comment