Skip to content

Instantly share code, notes, and snippets.

@janegilring
Created November 5, 2017 13:58
Show Gist options
  • Save janegilring/7c731974fe910a032b7a5d784ecdd366 to your computer and use it in GitHub Desktop.
Save janegilring/7c731974fe910a032b7a5d784ecdd366 to your computer and use it in GitHub Desktop.
Set-MailboxAutoReplyConfiguration runbook for use with Azure Automation
param (
[string]$UserName
)
# Credential for the user mailbox to configure Out-of-office schedule for
$UserCredential = Get-AutomationPSCredential -Name $UserName
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
$EXOModule = Import-PSSession $Session
# One hour earlier due to different time zone on the server side
$StartTime = Get-Date 07:00
$EndTime = Get-Date 15:00
# AutoReplyState = Enabled/Disabled/Scheduled
Set-MailboxAutoReplyConfiguration -Identity $UserName -StartTime $StartTime -EndTime $EndTime -AutoReplyState Scheduled
# Cleanup
Remove-Module -Name $EXOModule.Name
Remove-PSSession $Session
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment