Teams – Scripting and Music on Hold

A requests that I have received more than once from customers is to replace the default music on hold in Microsoft Teams.

At the moment there are some limitations in the way Teams manages the audio files for music on hold:

  1. Only call queues enable you to set music on hold. Auto Attendants have a greeting message that is not a replacement for the music on hold (see the images below)
Auto Attendant
Call Queue

2. There is no way (as I will show later) to use twice the same audio file. However, it is possible to script the process to avoid repeating the same operation for every Call Queue in the Teams Admin Center

3. Each time you upload an audio file using PowerShell with the Import-CsOnlineAudioFile cmdlet it is assigned a unique ID. There is no way to get that ID later

4. When you import the file, you have to select an ApplicationID. The name of the parameter could be confusing, but you have just two possible IDs

OrgAutoAttendant (used for Auto Attendants)
HuntGroup (used for Call Queues)

Now, let’s add some details to the scenario:

  • The audio file is called Loop.mp3 and I stored it in a local folder (C:\temp\audio)
  • I will use the Skype for Business Online, Windows PowerShell Module with a user that has already the required permissions

To upload the file, we have to save it into a variable (let’s call it $content)

$content = Get-Content “c:\temp\audio\Loop.mp3” -Encoding byte -ReadCount 0

There will be no need to repeat the above script. The audio file is now saved in the $content variable and we can reuse it every time.

Now we are going to import the file using the $content variable. The result will be an audio file usable for a Call Queue, whose display name will be “Loop2.mp3”

Import-CsOnlineAudioFile -ApplicationId “HuntGroup” -FileName “Loop2.mp3” -Content $content -Verbose

As you can see, we have the ID number for the file. We could copy and paste that one, or save those information in a variable. So, my suggestion is to use something like the following one:

$music1 = Import-CsOnlineAudioFile -ApplicationId “HuntGroup” -FileName “Loop2.mp3” -Content $content -Verbose

Now, $music1.id is going to have the Id number that we need to script the next step, for a example, defining a new Call Queue

New-CsCallQueue -Name “Example Group” -RoutingMethod Attendant -AllowOptOut $false -ConferenceMode $true -PresenceBasedRouting $true -AgentAlertTime 30 -TimeoutActionTarget “tel:+xxxxxxxxx” -TimeoutThreshold 30 -OverflowThreshold 50 -OverflowAction DisconnectWithBusy -TimeoutAction Forward -LanguageId en-GB MusicOnHoldAudioFileId $music1.id

Final note: it would be convenient to use the same uploaded file more than once. However, ss I said when I pointed out the limitations for Teams music on hold, if you try to use twice the same audio file you have an error “Ownership of the audio file (xxxxxxxxx) cannot be claimed

mm
About Fabrizio Volpe 95 Articles
I am an IT professional focused on Microsoft Teams, solution architect in Symity I have been awarded from Microsoft with the highly professional MVP award for Office Servers and Services: 2016 and 2017 Skype for Business: 2015 Lync Server 2013: 2014 Directory Services: 2011,2012 and 2013

2 Comments

  1. Very useful working on a few call queues.
    Any suggestions on downloading the previous greetings and music on hold from one Teams Tenant to migrate to another?

Leave a Reply

Your email address will not be published.


*


Time limit is exhausted. Please reload CAPTCHA.