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 https://ps.outlook.com/powershell/ -Credential $o365Cred -Authentication Basic -AllowRedirection Import-PSSession $Session
Summary
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.
Set Automatic Reply for specified users
You can use the below powershell commands to set out of office auto reply message for specified set of users.
$users = "[email protected]","[email protected]" ForEach ($user in $users) { Set-MailboxAutoReplyConfiguration -Identity $user -AutoReplyState Scheduled -StartTime "07/10/2018 01:00:00" -EndTime "7/15/2018 23:00:00" -InternalMessage "Internal out-of-office message" -ExternalMessage "Out of Office message for external mails." }
Use the following powershell commands to set out of office reply message for bulk users by importing users from CSV file.
Import-Csv 'C:\Users.csv' | ForEach-Object { $user = $_."UserPrincipalName" Set-MailboxAutoReplyConfiguration -Identity $user -AutoReplyState Scheduled -StartTime "07/10/2018 01:00:00" -EndTime "7/15/2018 23:00:00" -InternalMessage "Internal out-of-office message" -ExternalMessage "Out of Office message for external mails." }
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
I want not all user, just specified users. How can I do this?
Hello Morgan, thanks so much for this code:
Set-MailboxAutoReplyConfiguration -Identity "AlexW" -AutoReplyState Disabled -InternalMessage "" -ExternalMessage ""
That's exactly what I was looking for…..wanted to have auto reply just for external users, but they already had both internal and external set….so when I just set it to 'Disabled', it still generated a blank internal email once I set just the internal message. -InternalMessage "" -ExternalMessage "" was key!!
It is a very advantageous post for me. I've enjoyed reading the post. It is very supportive and useful post. I would like to visit the post once more its valuable content. Thanks!