Create Microsoft Teams Holidays for Switzerland 2023

Hi All,

In Microsoft Teams the Holidays have always been a bit Tricky.
You can create Holidays direct in Teams Admin Center under Voice > Holidays or during the Creation or Modification of a Autoattendant.

The Problem is that you create the Holidays and these are mostly set up to a specific Year. Next year you have to redo the Holidays and go through all Autoattendants to see if they are still linked.

I'll show you how to create and update the Microsoft Teams Holidays for Switzerland and keep them up do date.
I had considered diffrent approaches:
  • Create Holidays for each Day that exists in Switzerland
  • Create Holidays for each Canton in Switzerland (26 Kantone)
  • Create National Holidays and Holidays per Canton or Individual Dates
In the end i have created all Holidays - because i think that's the most flexible Model.


#List of Holidays in Teams
Connect-MicrosoftTeams
$Shedule = Get-CsOnlineSchedule | Where-Object {$_.Type -eq "Fixed"}
$Shedule
$Shedule.FixedSchedule
$Shedule.FixedSchedule.DateTimeRanges



I used the following Source for Reference

Add the Holidays for Switzerland in 2023

#Neujahr 01.01.2023
$DateRange = New-CsOnlineDateTimeRange -Start "2023-01-01T00:00:00" -End "2023-01-02T00:00:00"
New-CsOnlineSchedule -Name "Neujahr" -FixedSchedule -DateTimeRanges @($DateRange)

#Berchtoldstag 02.01.2023
$DateRange = New-CsOnlineDateTimeRange -Start "2023-01-02T00:00:00" -End "2023-01-03T00:00:00"
New-CsOnlineSchedule -Name "Berchtoldstag" -FixedSchedule -DateTimeRanges @($DateRange)

#Heilige Drei Könige 06.01.2023
$DateRange = New-CsOnlineDateTimeRange -Start "2023-01-06T00:00:00" -End "2023-01-07T00:00:00"
New-CsOnlineSchedule -Name "Heilige Drei Könige" -FixedSchedule -DateTimeRanges @($DateRange)

#St. Josef 19.03.2023
$DateRange = New-CsOnlineDateTimeRange -Start "2023-03-19T00:00:00" -End "2023-03-20T00:00:00"
New-CsOnlineSchedule -Name "St. Josef" -FixedSchedule -DateTimeRanges @($DateRange)

#Karfreitag 07.04.2023
$DateRange = New-CsOnlineDateTimeRange -Start "2023-04-07T00:00:00" -End "2023-04-08T00:00:00"
New-CsOnlineSchedule -Name "Karfreitag" -FixedSchedule -DateTimeRanges @($DateRange)

#Ostersonntag 09.04.2023
$DateRange = New-CsOnlineDateTimeRange -Start "2023-04-09T00:00:00" -End "2023-04-10T00:00:00"
New-CsOnlineSchedule -Name "Ostersonntag" -FixedSchedule -DateTimeRanges @($DateRange)

#Sechseläuten 17.04.2023
$DateRange = New-CsOnlineDateTimeRange -Start "2023-04-17T00:00:00" -End "2023-04-18T00:00:00"
New-CsOnlineSchedule -Name "Sechseläuten" -FixedSchedule -DateTimeRanges @($DateRange)

#Auffahrt 18.05.2023
$DateRange = New-CsOnlineDateTimeRange -Start "2023-05-18T00:00:00" -End "2023-05-19T00:00:00"
New-CsOnlineSchedule -Name "Auffahrt" -FixedSchedule -DateTimeRanges @($DateRange)

#Pfingstmontag 29.05.2023
$DateRange = New-CsOnlineDateTimeRange -Start "2023-05-29T00:00:00" -End "2023-05-30T00:00:00"
New-CsOnlineSchedule -Name "Pfingstmontag" -FixedSchedule -DateTimeRanges @($DateRange)

#Fronleichnam 08.06.2023
$DateRange = New-CsOnlineDateTimeRange -Start "2023-06-08T00:00:00" -End "2023-06-09T00:00:00"
New-CsOnlineSchedule -Name "Fronleichnam" -FixedSchedule -DateTimeRanges @($DateRange)

#Peter und Paul 29.06.2023
$DateRange = New-CsOnlineDateTimeRange -Start "2023-06-29T00:00:00" -End "2023-06-30T00:00:00"
New-CsOnlineSchedule -Name "Peter und Paul" -FixedSchedule -DateTimeRanges @($DateRange)

#Bundesfeier 01.08.2023
$DateRange = New-CsOnlineDateTimeRange -Start "2023-08-01T00:00:00" -End "2023-08-02T00:00:00"
New-CsOnlineSchedule -Name "Bundesfeier" -FixedSchedule -DateTimeRanges @($DateRange)

#Mariä Himmelfahrt 15.08.2023
$DateRange = New-CsOnlineDateTimeRange -Start "2023-08-15T00:00:00" -End "2023-08-16T00:00:00"
New-CsOnlineSchedule -Name "Mariä Himmelfahrt" -FixedSchedule -DateTimeRanges @($DateRange)

#Genfer Bettag 07.09.2023
$DateRange = New-CsOnlineDateTimeRange -Start "2023-09-07T00:00:00" -End "2023-09-08T00:00:00"
New-CsOnlineSchedule -Name "Genfer Bettag" -FixedSchedule -DateTimeRanges @($DateRange)

#Knabenschiessen 11.09.2023
$DateRange = New-CsOnlineDateTimeRange -Start "2023-09-11T00:00:00" -End "2023-09-12T00:00:00"
New-CsOnlineSchedule -Name "Knabenschiessen" -FixedSchedule -DateTimeRanges @($DateRange)

#Eidgenössischer Dank-, Buss- und Bettag 17.09.2023
$DateRange = New-CsOnlineDateTimeRange -Start "2023-09-17T00:00:00" -End "2023-09-18T00:00:00"
New-CsOnlineSchedule -Name "Eidgenössischer Dank-, Buss- und Bettag" -FixedSchedule -DateTimeRanges @($DateRange)

#Mauritiustag 22.09.2023
$DateRange = New-CsOnlineDateTimeRange -Start "2023-09-22T00:00:00" -End "2023-09-23T00:00:00"
New-CsOnlineSchedule -Name "Mauritiustag" -FixedSchedule -DateTimeRanges @($DateRange)

#St. Leodegar 02.10.2023
$DateRange = New-CsOnlineDateTimeRange -Start "2023-10-02T00:00:00" -End "2023-10-03T00:00:00"
New-CsOnlineSchedule -Name "St. Leodegar" -FixedSchedule -DateTimeRanges @($DateRange)

#Allerheiligen 01.11.2023
$DateRange = New-CsOnlineDateTimeRange -Start "2023-11-01T00:00:00" -End "2023-11-02T00:00:00"
New-CsOnlineSchedule -Name "Allerheiligen" -FixedSchedule -DateTimeRanges @($DateRange)

#Mariä Empfängnis 08.12.2023
$DateRange = New-CsOnlineDateTimeRange -Start "2023-12-08T00:00:00" -End "2023-12-09T00:00:00"
New-CsOnlineSchedule -Name "Mariä Empfängnis" -FixedSchedule -DateTimeRanges @($DateRange)

#Weihnachten 25.12.2023
$DateRange = New-CsOnlineDateTimeRange -Start "2023-12-25T00:00:00" -End "2023-12-26T00:00:00"
New-CsOnlineSchedule -Name "Weihnachten" -FixedSchedule -DateTimeRanges @($DateRange)

#Stephanstag 26.12.2023
$DateRange = New-CsOnlineDateTimeRange -Start "2023-12-26T00:00:00" -End "2023-12-27T00:00:00"
New-CsOnlineSchedule -Name "Stephanstag" -FixedSchedule -DateTimeRanges @($DateRange)




Now all the Holidays have been created.


#Show global Holidays
$Schedule = Get-CsOnlineSchedule | Where-Object {$_.Type -eq "Fixed"}
$Schedule | Select-Object Name,  @{label="Start";expression={$_.FixedSchedule.DateTimeRanges[0].Start}}, @{label="End";expression={$_.FixedSchedule.DateTimeRanges[0].End}} | Sort-Object Start




Now it's a little bit tricky. Because every canton in Switzerland (similar to US federal States) has it's own rules if these Holidays are free days or not.

In Teams Admin Center you add the Holidays like this: Select the Auto Attendant


Click on "Add"


Now you need to provide a Name for the Holiday. I simply use the same Name as the in the Holidays (Get-CsOnlineSchedule).
Then you can select from the Dropdown List and set Greeting and Call routing options.


Don't forget to Save at the End (Bottom of Window that is not part of the Screenshot)


Same in PowerShell

#Add Holiday to AutoAttendant
$AutoAttendantName = "AutoAttendantDemo01"
$HolidayName = "Berchtoldstag"
$HolidaySchedule = Get-CsOnlineSchedule | Where-Object {$_.Name -eq $HolidayName}
$HolidayScheduleName = $HolidaySchedule.Name
$GreetingPrompt = New-CsAutoAttendantPrompt -TextToSpeechPrompt "An Feiertagen sind wir nicht erreichbar"
$MenuOption = New-CsAutoAttendantMenuOption -Action DisconnectCall -DtmfResponse Automatic
$Menu = New-CsAutoAttendantMenu -Name $HolidayScheduleName -MenuOptions @($MenuOption)
$CallFlow = New-CsAutoAttendantCallFlow -Name $HolidayScheduleName -Menu $Menu -Greetings $GreetingPrompt
$CallHandlingAssociation = New-CsAutoAttendantCallHandlingAssociation -Type Holiday -ScheduleId $HolidaySchedule.Id -CallFlowId $CallFlow.Id
$AutoAttendant = Get-CsAutoAttendant -NameFilter $AutoAttendantName
$AutoAttendant.CallFlows += @($CallFlow)
$AutoAttendant.CallHandlingAssociations += @($CallHandlingAssociation)
Set-CsAutoAttendant -Instance $AutoAttendant



The Holiday has been addet to the Autoattendant.


By the way, this is the Code to remove a Holiday from an Auto Attendant

#Remove Holiday from AutoAttendant
$AutoAttendantName = "AutoAttendantDemo01"
$HolidayName = "Neujahr"
$AutoAttendant = Get-CsAutoAttendant -NameFilter $AutoAttendantName
$CallFlows = $AutoAttendant.CallFlows | Where-Object {$_.Name -ne $HolidayName}
$CallFlow = $AutoAttendant.CallFlows | Where-Object {$_.Name -eq $HolidayName}
$CallHandlingAssociations = $AutoAttendant.CallHandlingAssociations | Where-Object {$_.CallFlowId -ne $CallFlow.Id}
$AutoAttendant.CallFlows = @($CallFlows)
$AutoAttendant.CallHandlingAssociations = @($CallHandlingAssociations)
Set-CsAutoAttendant -Instance $AutoAttendant


Now let's see the Holidays for an Auto Attendant

#Show Holidays from Autoattendant
$AutoAttendantName = "AutoAttendantDemo01"
$AutoAttendant = Get-CsAutoAttendant -NameFilter $AutoAttendantName
$AutoAttendant.Schedule
$AutoAttendantHolidays = Get-CsAutoAttendantHolidays -Identity $AutoAttendant.Identity
$AutoAttendantHolidays
$AutoAttendantHolidays.DateTimeRanges



So next Year you simply need to update the Holidays. Here is an Example of how to do that for "Neujahr".

#Update Holiday 2024
$HolidayName = "Neujahr"
$DateRange = New-CsOnlineDateTimeRange -Start "2024-01-01T00:00:00" -End "2024-01-02T00:00:00"
$Neujahr = Get-CsOnlineSchedule | Where-Object {$_.Name -eq $HolidayName}
$Neujahr.FixedSchedule.DateTimeRanges = $DateRange
Set-CsOnlineSchedule -Instance $Neujahr



The Holiday has been updated


And the Associated Holiday in the Teams Auto Attendand also has the new Date.



Hope that help you to make your Teams Holidays more smart and easy to maintain.

Regards
Andres Bohren