Forum Discussion
Powershell adding a existing holiday to Auto Attendant
Hello
I have to add an existing Holiday to Auto Attendant and have this script
# Connect to Microsoft Teams
# Connect-MicrosoftTeams
# Variables - Replace with your actual values
$autoAttendantName = "AA_Test"
$holidaySetName = "Holiday"
#$audioFilePath = "Paht\test.wav" # Path to your audio file
# 1. Upload Audio File as Prompt
$content = [System.IO.File]::ReadAllBytes('Path\test.wav')
$audioFile = Import-CsOnlineAudioFile -ApplicationId "OrgAutoAttendant" -FileName "test.wav" -Content $content
$audioPrompt = New-CsAutoAttendantPrompt -AudioFilePrompt $audioFile
# 2. Create Holiday Call Flow with Disconnect Option
$holidayCallFlow = New-CsAutoAttendantCallFlow -Name "Holiday Call Flow" `
-Greetings @($audioPrompt) `
-MenuOptions @(
New-CsAutoAttendantMenuOption -Action Disconnect -DtmfResponse Automatic
)
# 3. Get existing Auto Attendant and Holiday Set
$aa = Get-CsAutoAttendant -Namefilter $autoAttendantName
$holidaySet = Get-CsAutoAttendantHolidaySet -Name $holidaySetName
# 4. Link Holiday Set and Call Flow to Auto Attendant
Set-CsAutoAttendant -Identity $aa.Identity `
-HolidaySets @($holidaySet.Identity) `
-HolidayCallFlow $holidayCallFlow.Identity
# 5. Verify
Get-CsAutoAttendant -Identity $autoAttendantName | Select-Object Name, HolidaySets, HolidayCallFlowI do get following error
Microsoft.Teams.ConfigAPI.Cmdlets.internal\Import-CsOnlineAudioFile : Expected '{' or '['. Was String: Exception.
At C:\Program Files\WindowsPowerShell\Modules\MicrosoftTeams\7.5.0\custom\Merged_custom_PsExt.ps1:7245 char:13
+ $internalOutput = Microsoft.Teams.ConfigAPI.Cmdlets.inter ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Import-CsOnlineAudioFile_ImportExpanded], ParserException
+ FullyQualifiedErrorId : Microsoft.Teams.ConfigAPI.Cmdlets.Generated.Cmdlets.ImportCsOnlineAudioFile_ImportExpanded
Where is the mistake
Thanks and have a great day
JFM_12
1 Reply
- Nivedipa-MSFT
Microsoft
Hello @JFM_12 - Thanks for bringing this issue to our attention.
The error occurs because Import-CsOnlineAudioFile expects the -Content parameter as a byte array, but the way you're passing it may not be compatible with the cmdlet's internal processing.
Fix:
Replace this line:
$content = [System.IO.File]::ReadAllBytes('Path\test.wav') $audioFile = Import-CsOnlineAudioFile -ApplicationId "OrgAutoAttendant" -FileName "test.wav" -Content $contentWith:
$audioFile = Import-CsOnlineAudioFile -ApplicationId "OrgAutoAttendant" -FileName "test.wav" -Content ([System.IO.File]::ReadAllBytes('Path\test.wav'))
Please let us know if you have any further query.