Last active
September 8, 2022 14:09
-
-
Save mozziemozz/389d9107fdd2cf5f0727c331ec27d636 to your computer and use it in GitHub Desktop.
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
| # Author: Martin Heusser (@mozzeph) | |
| Connect-MicrosoftTeams | |
| $autoAttendantSelection = Get-CsAutoAttendant | Select-Object Name, Identity| Out-GridView -Title "Choose an Auto Attendant from the list." -PassThru | |
| $tr1 = New-CsOnlineTimeRange -Start 08:15 -End 12:00 | |
| $tr2 = New-CsOnlineTimeRange -Start 13:30 -End 17:45 | |
| #$tr3 = New-CsOnlineTimeRange -Start 08:30 -End 16:00 | |
| $autoAttendant = Get-CsAutoAttendant -Identity $autoAttendantSelection.Identity | |
| $autoAttendant.CallHandlingAssociations | |
| $ExportCallFlow = $autoAttendant.Callflows | Where-Object {$_.Id -eq ($autoAttendant.CallHandlingAssociations | Where-Object {$_.Type -eq "AfterHours"}).CallFlowId} | |
| $BuildCallFlow = New-Object psobject | |
| $BuildCallFlow | Add-Member -MemberType NoteProperty -Name "Id" -Value $ExportCallFlow.Id | |
| $BuildCallFlow | Add-Member -MemberType NoteProperty -Name "Name" -Value $ExportCallFlow.Name | |
| $BuildCallFlow | Add-Member -MemberType NoteProperty -Name "Greetings" -Value $ExportCallFlow.Greetings | |
| $BuildCallFlow | Add-Member -MemberType NoteProperty -Name "Menu" -Value $ExportCallFlow.Menu | |
| $ExportCallHandlindAssociation = $autoAttendant.CallHandlingAssociations | Where-Object {$_.Type -match "AfterHours"} | |
| $BuildCallHandlingAssociation = New-Object psobject | |
| $BuildCallHandlingAssociation | Add-Member -MemberType NoteProperty -Name "Type" -Value $ExportCallHandlindAssociation.Type | |
| $BuildCallHandlingAssociation | Add-Member -MemberType NoteProperty -Name "ScheduleId" -Value $ExportCallHandlindAssociation.ScheduleId | |
| $BuildCallHandlingAssociation | Add-Member -MemberType NoteProperty -Name "CallFlowId" -Value $ExportCallHandlindAssociation.CallFlowId | |
| $BuildCallHandlingAssociation | Add-Member -MemberType NoteProperty -Name "Enabled" -Value $ExportCallHandlindAssociation.Enabled | |
| $autoAttendant.CallHandlingAssociations = $autoAttendant.CallHandlingAssociations | Where-Object {$_.Type -notmatch "AfterHours"} | |
| $autoAttendant.CallFlows | |
| $autoAttendant.CallFlows = $autoAttendant.CallFlows | Where-Object {$_.Name -notmatch "After hours Call Flow"} | |
| $schedule = New-CsOnlineSchedule -Name "After Hours" -WeeklyRecurrentSchedule -MondayHours @($tr1,$tr2) -TuesdayHours @($tr1,$tr2) -WednesdayHours @($tr1,$tr2) -ThursdayHours @($tr1,$tr2) -FridayHours @($tr1,$tr2) -Complement | |
| $scheduleId = $schedule.Id | |
| $callHandlingAssociation = New-CsAutoAttendantCallHandlingAssociation -Type AfterHours -ScheduleId $ScheduleId -CallFlowId $BuildCallHandlingAssociation.CallFlowId | |
| $autoAttendant.CallFlows += @($BuildCallFlow) | |
| $autoAttendant.CallHandlingAssociations += @($CallHandlingAssociation) | |
| Set-CsAutoAttendant -Instance $autoAttendant |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment