Created
March 11, 2021 15:40
-
-
Save SibeeshVenu/5d6e40e087c90202e4ff78310675a0cc to your computer and use it in GitHub Desktop.
PowerShell function to configure the out of office reply message automatically for all the holidays in your calendar, provided set up the calendar by following this blog: https://www.msoutlook.info/question/show-holidays-as-busy-or-out-of-office
This file contains 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
Function Configure-OutOfOffice-Message | |
{ | |
Add-Type -AssemblyName 'Microsoft.Office.Interop.Outlook' | |
$outlook = New-Object -ComObject outlook.application | |
$namespace = $outlook.GetNameSpace('MAPI') | |
$Calendar = [Microsoft.Office.Interop.Outlook.OlDefaultFolders]::olFolderCalendar | |
$folder = $namespace.getDefaultFolder($Calendar) | |
$Holidays = $folder.items | | |
Select-Object -Property Start, Categories | Where-Object Start -ge (Get-Date).AddDays(-1) | Where-Object Categories -eq 'Holiday' | |
Foreach($holiday in $Holidays) | |
{ | |
Set-MailboxAutoReplyConfiguration -identity alias -AutoReplyState Scheduled -StartTime $holiday.Start -EndTime $holiday.Start -InternalMessage "Thank you for your email. I am out of office today, I will get back you as soon as possible. Have a great day!" -ExternalMessage "Thank you for your email. I am out of office today, I will get back you as soon as possible. Have a great day!" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment