Forum Discussion

Andre Hagmann's avatar
Andre Hagmann
Copper Contributor
Apr 25, 2022

BUG with Microsoft Teams PowerShell Module 4.x.x for Auto Attendant Management

Dear Microsoft Community

 

I have a working PowerShell Script for toggling a Microsoft Teams Auto Attendant target between CallQueue or a ExternalPstn. Developed since PowerShell Module Version 2.0.0 up to Version 3.0.0.

 

The main part of the Script for updating the $AutoAttendant.DefaultCallFlow.Menu.MenuOptions is the following

 

$AutoAttendant = Get-CsAutoAttendant | Where-object {$_.Identity -eq $($Identity)}

$First = $AutoAttendant.DefaultCallFlow.Menu.MenuOptions | Select-Object -First 1
$AutoAttendant.DefaultCallFlow.Menu.MenuOptions.Remove($First)

 

Switch ($Target) 
{
"ApplicationEndpoint" {

$CallQueue = New-CsAutoAttendantCallableEntity -Identity $($ResourceAccount) -Type ApplicationEndpoint
$MenuOption = New-CsAutoAttendantMenuOption -Action TransferCallToTarget -CallTarget $($CallQueue) -DtmfRespons Automatic
($AutoAttendant.DefaultCallFlow.Menu.MenuOptions.Add($($MenuOption))) | Out-Null
}

"ExternalPstn" {

$PhoneNumber = New-CsAutoAttendantCallableEntity -Identity "tel:$($Global:CurrentPhoneNumber.Line)" -Type ExternalPstn
$MenuOption = New-CsAutoAttendantMenuOption -Action TransferCallToTarget -CallTarget $($PhoneNumber) -DtmfRespons Automatic
($AutoAttendant.DefaultCallFlow.Menu.MenuOptions.Add($($MenuOption))) | Out-Null
}
}

 

But since Microsoft Teams PowerShell Module Version 4.0.0 or current 4.2.0, i receive an error removing the first MenuOptions  Entry at following script line $AutoAttendant.DefaultCallFlow.Menu.MenuOptions.Remove($First)

 

Exception calling "Remove" with "1" argument(s): "Collection was of a fixed size."
At line:1 char:1
+ $AutoAttendant.DefaultCallFlow.Menu.MenuOptions.Remove($First)
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : NotSupportedException

 

is this a known Issues of the current PowerShell Module and what is the plan for a fix.

 

many thanks

Andy

 

 

 

6 Replies

Resources