Tuesday, August 20, 2019

Office 365 - How to set an Automatic Reply / Out of Office via Powershell

At some point, as an Office 365 administrator, it is likely you will be asked to set an automatic reply for someone who forgot to do so themselves. 

You can easily do so via PowerShell by first connecting to the Office 365 Exchange module:


$Credential = Get-Credential

$Session = New-PSSession -ConfigurationName Microsoft.exchange -ConnectionURI https://outlook.office365.com/powershell-liveid/ -Credential $Credential -Authentication Basic -AllowRedirection

Import-PSSession $Session


And once connected run the following command:


Set-MailboxAutoReplyConfiguration -Identity user@contoso.com -AutoReplyState Enabled -ExternalMessage $msg -InternalMessage $msg -ExternalAudience All

$msg = ‘<html><body><div><p>Set Automatic Reply Message Here!</p><p>Next line will go here!</p></div></body></html>’


Once the above command is run, the user@contoso.com account will immediately begin to send automatic replies.

To disable the users Automatic Reply


To disable this users Automatic Reply, run the following:


Set-MailboxAutoReplyConfiguration -Identity user@contoso.com -AutoReplyState Disabled


Run this command to disable the auto reply as well as clear out the message:


Set-MailboxAutoReplyConfiguration -Identity user@contoso.com -AutoReplyState Disabled -InternalMessage "" -ExternalMessage ""



No comments:

Post a Comment