skip to Main Content

Set automatic replies with PowerShell

How to set Automatic Replies for another user with PowerShell in Exchange Server? The user has left work and forgot to change his Out of Office in Outlook. He gets many emails and wants to keep his internal colleagues and external partners notified. He asked if it’s possible to change the text in his Out of Office and enable it. In this article, you will learn how to set Automatic Replies with PowerShell in Exchange Server.

Information

In our example, we will look at how to get Automatic Reply and set Automatic Reply. After that, we will show a screenshot of the Automatic Replies (Out of Office) configuration in Microsoft Outlook.

Get mailbox Automatic Reply status

Run Exchange Management Shell as administrator. Check if Automatic Reply is enabled on the mailbox of the user. Make use of the cmdlet Get-MailboxAutoReplyConfiguration.

[PS] C:\>Get-MailboxAutoReplyConfiguration -Identity "James.Paterson@exoip.com"


RunspaceId                       : ecc5c541-9185-4ecb-b304-2f6a794024c9
AutoDeclineFutureRequestsWhenOOF : False
AutoReplyState                   : Disabled
CreateOOFEvent                   : False
DeclineAllEventsForScheduledOOF  : False
DeclineEventsForScheduledOOF     : False
EventsToDeleteIDs                :
EndTime                          : 8/7/2020 5:00:00 PM
ExternalAudience                 : All
ExternalMessage                  :
InternalMessage                  :
DeclineMeetingMessage            :
OOFEventSubject                  :
StartTime                        : 8/6/2020 5:00:00 PM
MailboxOwnerId                   : exoip.local/Company/Users/IT/James Paterson
Identity                         : exoip.local/Company/Users/IT/James Paterson
IsValid                          : True
ObjectState                      : Unchanged

The AutoReplyState value is showing as disabled. This means that Automatic replies are disabled for the user. InternalMessage and ExternalMessage are empty, which means the user does not have any text filled in the text box.

Set automatic replies with PowerShell 1

Read more: Get users that have Out of Office enabled in Exchange »

Enable Automatic Replies and set internal and external message

Enable Automatic Replies with a message for both internal and external senders.

[PS] C:\>Set-MailboxAutoReplyConfiguration –Identity "James.Paterson@exoip.com" -AutoReplyState Enabled –InternalMessage "Internal auto-reply test." –ExternalMessage "External auto-reply test." -ExternalAudience All

[PS] C:\>Get-MailboxAutoReplyConfiguration -Identity "James.Paterson@exoip.com"


RunspaceId                       : ecc5c541-9185-4ecb-b304-2f6a794024c9
AutoDeclineFutureRequestsWhenOOF : False
AutoReplyState                   : Enabled
CreateOOFEvent                   : False
DeclineAllEventsForScheduledOOF  : False
DeclineEventsForScheduledOOF     : False
EventsToDeleteIDs                :
EndTime                          : 8/7/2020 5:00:00 PM
ExternalAudience                 : All
ExternalMessage                  : <html>
                                   <body>
                                   External auto-reply test.
                                   </body>
                                   </html>

InternalMessage                  : <html>
                                   <body>
                                   Internal auto-reply test.
                                   </body>
                                   </html>

DeclineMeetingMessage            :
OOFEventSubject                  :
StartTime                        : 8/6/2020 5:00:00 PM
MailboxOwnerId                   : exoip.local/Company/Users/IT/James Paterson
Identity                         : exoip.local/Company/Users/IT/James Paterson
IsValid                          : True
ObjectState                      : Unchanged
Set automatic replies with PowerShell 2

Now that we have seen how you can change the Automatic Replies of the user, what’s next? There are more options to change the Automatic Replies of the user. Let’s check them out.

Enable Automatic Replies scheduled time for internal and external messages

Enable Automatic Replies with a scheduled time and date starting from 20-8-2020 10:00 till 20/8/2020 12:00.

[PS] C:\>Set-MailboxAutoReplyConfiguration -Identity "James.Paterson@exoip.com" -AutoReplyState Scheduled -StartTime "8/20/2020 10:00" -EndTime "8/20/2020 12:00" -InternalMessage "Internal auto-reply test date 20 August." -ExternalMessage "External auto-reply test date 20 August."

[PS] C:\>Get-MailboxAutoReplyConfiguration -Identity "James.Paterson@exoip.com"


RunspaceId                       : ecc5c541-9185-4ecb-b304-2f6a794024c9
AutoDeclineFutureRequestsWhenOOF : False
AutoReplyState                   : Scheduled
CreateOOFEvent                   : False
DeclineAllEventsForScheduledOOF  : False
DeclineEventsForScheduledOOF     : False
EventsToDeleteIDs                :
EndTime                          : 8/20/2020 12:00:00 PM
ExternalAudience                 : All
ExternalMessage                  : <html>
                                   <body>
                                   External auto-reply test date 20 August.
                                   </body>
                                   </html>

InternalMessage                  : <html>
                                   <body>
                                   Internal auto-reply test date 20 August.
                                   </body>
                                   </html>

DeclineMeetingMessage            :
OOFEventSubject                  :
StartTime                        : 8/20/2020 10:00:00 AM
MailboxOwnerId                   : exoip.local/Company/Users/IT/James Paterson
Identity                         : exoip.local/Company/Users/IT/James Paterson
IsValid                          : True
ObjectState                      : Unchanged

Remove time range in Automatic Replies

Edit Automatic Replies by removing the time scheduling and edit the internal message.

[PS] C:\>Set-MailboxAutoReplyConfiguration -Identity "James.Paterson@exoip.com" -AutoReplyState Enabled -InternalMessage "Internal auto-reply test."

[PS] C:\>Get-MailboxAutoReplyConfiguration -Identity "James.Paterson@exoip.com"


RunspaceId                       : ecc5c541-9185-4ecb-b304-2f6a794024c9
AutoDeclineFutureRequestsWhenOOF : False
AutoReplyState                   : Enabled
CreateOOFEvent                   : False
DeclineAllEventsForScheduledOOF  : False
DeclineEventsForScheduledOOF     : False
EventsToDeleteIDs                :
EndTime                          : 8/7/2020 5:00:00 PM
ExternalAudience                 : All
ExternalMessage                  : <html>
                                   <body>
                                   External auto-reply test date 20 August.
                                   </body>
                                   </html>

InternalMessage                  : <html>
                                   <body>
                                   Internal auto-reply test.
                                   </body>
                                   </html>

DeclineMeetingMessage            :
OOFEventSubject                  :
StartTime                        : 8/6/2020 5:00:00 PM
MailboxOwnerId                   : exoip.local/Company/Users/IT/James Paterson
Identity                         : exoip.local/Company/Users/IT/James Paterson
IsValid                          : True
ObjectState                      : Unchanged
Set automatic replies with PowerShell 4

Clear and disable external message in Automatic Replies

Clear and disable the external message in Automatic Replies.

[PS] C:\>Set-MailboxAutoReplyConfiguration -Identity "James.Paterson@exoip.com" -AutoReplyState Enabled -InternalMessage "Internal auto-reply test." -ExternalMessage $null -ExternalAudience None

[PS] C:\>Get-MailboxAutoReplyConfiguration -Identity "James.Paterson@exoip.com"


RunspaceId                       : ecc5c541-9185-4ecb-b304-2f6a794024c9
AutoDeclineFutureRequestsWhenOOF : False
AutoReplyState                   : Enabled
CreateOOFEvent                   : False
DeclineAllEventsForScheduledOOF  : False
DeclineEventsForScheduledOOF     : False
EventsToDeleteIDs                :
EndTime                          : 8/7/2020 5:00:00 PM
ExternalAudience                 : None
ExternalMessage                  :
InternalMessage                  : <html>
                                   <body>
                                   Internal auto-reply test.
                                   </body>
                                   </html>

DeclineMeetingMessage            :
OOFEventSubject                  :
StartTime                        : 8/6/2020 5:00:00 PM
MailboxOwnerId                   : exoip.local/Company/Users/IT/James Paterson
Identity                         : exoip.local/Company/Users/IT/James Paterson
IsValid                          : True
ObjectState                      : Unchanged
Set automatic replies with PowerShell 5

Change external message and enable only for contacts

Keep the internal message. The external message needs to be changed and configured for his contacts list only.

[PS] C:\>Set-MailboxAutoReplyConfiguration -Identity "James.Paterson@exoip.com" -AutoReplyState Enabled -ExternalMessage "External auto-reply test only contacts." -ExternalAudience Known

[PS] C:\>Get-MailboxAutoReplyConfiguration -Identity "James.Paterson@exoip.com"


RunspaceId                       : ecc5c541-9185-4ecb-b304-2f6a794024c9
AutoDeclineFutureRequestsWhenOOF : False
AutoReplyState                   : Enabled
CreateOOFEvent                   : False
DeclineAllEventsForScheduledOOF  : False
DeclineEventsForScheduledOOF     : False
EventsToDeleteIDs                :
EndTime                          : 8/7/2020 6:00:00 PM
ExternalAudience                 : Known
ExternalMessage                  : <html>
                                   <body>
                                   External auto-reply test only contacts.
                                   </body>
                                   </html>

InternalMessage                  : <html>
                                   <body>
                                   Internal auto-reply test.
                                   </body>
                                   </html>

DeclineMeetingMessage            :
OOFEventSubject                  :
StartTime                        : 8/6/2020 6:00:00 PM
MailboxOwnerId                   : exoip.local/Company/Users/IT/James Paterson
Identity                         : exoip.local/Company/Users/IT/James Paterson
IsValid                          : True
ObjectState                      : Unchanged

Disable Automatic Replies

Disable Automatic Replies but keep the messages that you have configured. You can enable Automatic Replies the next time, without entering the text again.

[PS] C:\>Set-MailboxAutoReplyConfiguration -Identity "James.Paterson@exoip.com" -AutoreplyState Disabled

[PS] C:\>Get-MailboxAutoReplyConfiguration -Identity "James.Paterson@exoip.com"


RunspaceId                       : ecc5c541-9185-4ecb-b304-2f6a794024c9
AutoDeclineFutureRequestsWhenOOF : False
AutoReplyState                   : Disabled
CreateOOFEvent                   : False
DeclineAllEventsForScheduledOOF  : False
DeclineEventsForScheduledOOF     : False
EventsToDeleteIDs                :
EndTime                          : 8/7/2020 6:00:00 PM
ExternalAudience                 : Known
ExternalMessage                  : <html>
                                   <body>
                                   External auto-reply test only contacts.
                                   </body>
                                   </html>

InternalMessage                  : <html>
                                   <body>
                                   Internal auto-reply test.
                                   </body>
                                   </html>

DeclineMeetingMessage            :
OOFEventSubject                  :
StartTime                        : 8/6/2020 6:00:00 PM
MailboxOwnerId                   : exoip.local/Company/Users/IT/James Paterson
Identity                         : exoip.local/Company/Users/IT/James Paterson
IsValid                          : True
ObjectState                      : Unchanged
Set automatic replies with PowerShell 7

Disable Automatic Replies and clear internal and external message

Disable Automatic Replies and clear the internal and external auto-reply messages.

[PS] C:\>Set-MailboxAutoReplyConfiguration -Identity "James.Paterson@exoip.com" -AutoReplyState Disabled -ExternalAudience All -ExternalMessage $null -InternalMessage $null

[PS] C:\>Get-MailboxAutoReplyConfiguration -Identity "James.Paterson@exoip.com"


RunspaceId                       : ecc5c541-9185-4ecb-b304-2f6a794024c9
AutoDeclineFutureRequestsWhenOOF : False
AutoReplyState                   : Disabled
CreateOOFEvent                   : False
DeclineAllEventsForScheduledOOF  : False
DeclineEventsForScheduledOOF     : False
EventsToDeleteIDs                :
EndTime                          : 8/7/2020 6:00:00 PM
ExternalAudience                 : All
ExternalMessage                  :
InternalMessage                  :
DeclineMeetingMessage            :
OOFEventSubject                  :
StartTime                        : 8/6/2020 6:00:00 PM
MailboxOwnerId                   : exoip.local/Company/Users/IT/James Paterson
Identity                         : exoip.local/Company/Users/IT/James Paterson
IsValid                          : True
ObjectState                      : Unchanged
Set automatic replies with PowerShell

I hope that this helped you to set the Automatic Replies with PowerShell in Exchange Server.

Keep on reading: Search message tracking logs in Exchange »

Conclusion

In this article, you learned how to set Automatic Replies with PowerShell. First, get the Automatic Reply status of the user, then edit the configuration. Not only did you see one option to adjust the Automatic Reply, but you saw many more variations. Microsoft has written a useful document about the Mailbox Automatic Reply configuration.

If you enjoyed this article, you may also like Search and delete email from Exchange user mailbox. Don’t forget to follow us.

ALI TAJRAN

ALI TAJRAN

ALI TAJRAN is a passionate IT Architect, IT Consultant, and Microsoft Certified Trainer. He started Information Technology at a very young age, and his goal is to teach and inspire others. Read more »

This Post Has 0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *