Created
November 5, 2017 13:58
-
-
Save janegilring/7c731974fe910a032b7a5d784ecdd366 to your computer and use it in GitHub Desktop.
Set-MailboxAutoReplyConfiguration runbook for use with Azure Automation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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