{"id":2017,"date":"2020-11-25T18:09:12","date_gmt":"2020-11-25T18:09:12","guid":{"rendered":"https:\/\/modern-workplace.uk\/?p=2017"},"modified":"2020-11-25T18:18:52","modified_gmt":"2020-11-25T18:18:52","slug":"teams-scripting-and-music-on-hold","status":"publish","type":"post","link":"https:\/\/modern-workplace.uk\/?p=2017","title":{"rendered":"Teams &#8211; Scripting and Music on Hold"},"content":{"rendered":"\n<p class=\"has-normal-font-size\">A requests that I have received more than once from customers is to replace the default music on hold  in Microsoft Teams.<\/p>\n\n\n\n<p>At the moment there are some limitations in the way Teams manages the audio files for music on hold:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>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)<\/li><\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"357\" src=\"https:\/\/modern-workplace.uk\/wp-content\/uploads\/2020\/04\/AutoAttendant-1024x357.jpg\" alt=\"\" class=\"wp-image-2020\" srcset=\"https:\/\/modern-workplace.uk\/wp-content\/uploads\/2020\/04\/AutoAttendant-1024x357.jpg 1024w, https:\/\/modern-workplace.uk\/wp-content\/uploads\/2020\/04\/AutoAttendant-300x105.jpg 300w, https:\/\/modern-workplace.uk\/wp-content\/uploads\/2020\/04\/AutoAttendant-768x268.jpg 768w, https:\/\/modern-workplace.uk\/wp-content\/uploads\/2020\/04\/AutoAttendant.jpg 1240w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption><span class=\"has-inline-color has-vivid-green-cyan-color\">Auto Attendant<\/span><\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"386\" src=\"https:\/\/modern-workplace.uk\/wp-content\/uploads\/2020\/04\/CallQueues-1024x386.jpg\" alt=\"\" class=\"wp-image-2021\" srcset=\"https:\/\/modern-workplace.uk\/wp-content\/uploads\/2020\/04\/CallQueues-1024x386.jpg 1024w, https:\/\/modern-workplace.uk\/wp-content\/uploads\/2020\/04\/CallQueues-300x113.jpg 300w, https:\/\/modern-workplace.uk\/wp-content\/uploads\/2020\/04\/CallQueues-768x289.jpg 768w, https:\/\/modern-workplace.uk\/wp-content\/uploads\/2020\/04\/CallQueues.jpg 1468w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption><span class=\"has-inline-color has-vivid-green-cyan-color\">Call Queue<\/span><\/figcaption><\/figure>\n\n\n\n<p>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<\/p>\n\n\n\n<p>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<\/p>\n\n\n\n<p>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<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><em>OrgAutoAttendant<\/em>     (used for Auto Attendants)<br><em>HuntGroup<\/em>     (used for Call Queues)<\/p><\/blockquote>\n\n\n\n<p>Now, let&#8217;s add some details to the scenario:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>The audio file is called Loop.mp3 and I stored it in a local folder (C:\\temp\\audio)<\/li><li>I will use the Skype for Business Online, Windows PowerShell Module with a user that has already the required permissions<\/li><\/ul>\n\n\n\n<p>To upload the file, we have to save it into a variable (let&#8217;s call it $content) <\/p>\n\n\n\n<p><em><span style=\"color:#2600ff\" class=\"has-inline-color\">$content = Get-Content &#8220;c:\\temp\\audio\\Loop.mp3&#8221; -Encoding byte -ReadCount 0<\/span><\/em><\/p>\n\n\n\n<p>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.<\/p>\n\n\n\n<p>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 &#8220;Loop2.mp3&#8221;<\/p>\n\n\n\n<p><em><span style=\"color:#2600ff\" class=\"has-inline-color\">Import-CsOnlineAudioFile -ApplicationId &#8220;HuntGroup&#8221; -FileName &#8220;Loop2.mp3&#8221; -Content $content -Verbose<\/span><\/em><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1004\" height=\"109\" src=\"https:\/\/modern-workplace.uk\/wp-content\/uploads\/2020\/04\/Import1.jpg\" alt=\"\" class=\"wp-image-2025\" srcset=\"https:\/\/modern-workplace.uk\/wp-content\/uploads\/2020\/04\/Import1.jpg 1004w, https:\/\/modern-workplace.uk\/wp-content\/uploads\/2020\/04\/Import1-300x33.jpg 300w, https:\/\/modern-workplace.uk\/wp-content\/uploads\/2020\/04\/Import1-768x83.jpg 768w\" sizes=\"auto, (max-width: 1004px) 100vw, 1004px\" \/><\/figure>\n\n\n\n<p>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:<\/p>\n\n\n\n<p><em><span style=\"color:#2600ff\" class=\"has-inline-color\">$music1 = Import-CsOnlineAudioFile -ApplicationId &#8220;HuntGroup&#8221; -FileName &#8220;Loop2.mp3&#8221; -Content $content -Verbose<\/span><\/em><\/p>\n\n\n\n<p>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<\/p>\n\n\n\n<p><em><span style=\"color:#2600ff\" class=\"has-inline-color\">New-CsCallQueue -Name &#8220;Example Group&#8221; -RoutingMethod Attendant -AllowOptOut $false -ConferenceMode $true -PresenceBasedRouting $true -AgentAlertTime 30 -TimeoutActionTarget &#8220;tel:+xxxxxxxxx&#8221; -TimeoutThreshold 30 -OverflowThreshold 50 -OverflowAction DisconnectWithBusy -TimeoutAction Forward -LanguageId en-GB <\/span><span class=\"has-inline-color has-luminous-vivid-orange-color\">&#8211;<\/span><strong><span class=\"has-inline-color has-luminous-vivid-orange-color\">MusicOnHoldAudioFileId $music1.id<\/span><\/strong><\/em><\/p>\n\n\n\n<p>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 &#8220;Ownership of the audio file (xxxxxxxxx) cannot be claimed<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"67\" src=\"https:\/\/modern-workplace.uk\/wp-content\/uploads\/2020\/04\/OwnershipError-1024x67.jpg\" alt=\"\" class=\"wp-image-2026\" srcset=\"https:\/\/modern-workplace.uk\/wp-content\/uploads\/2020\/04\/OwnershipError-1024x67.jpg 1024w, https:\/\/modern-workplace.uk\/wp-content\/uploads\/2020\/04\/OwnershipError-300x20.jpg 300w, https:\/\/modern-workplace.uk\/wp-content\/uploads\/2020\/04\/OwnershipError-768x50.jpg 768w, https:\/\/modern-workplace.uk\/wp-content\/uploads\/2020\/04\/OwnershipError.jpg 1051w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>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: Only call queues enable you to set music on hold. Auto Attendants have a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2030,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_sitemap_exclude":false,"_sitemap_priority":"","_sitemap_frequency":"","twitterCardType":"","cardImageID":0,"cardImage":"","cardTitle":"","cardDesc":"","cardImageAlt":"","cardPlayer":"","cardPlayerWidth":0,"cardPlayerHeight":0,"cardPlayerStream":"","cardPlayerCodec":"","footnotes":""},"categories":[758,753,752,757],"tags":[759,751,77,755],"class_list":["post-2017","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-758","category-microsoft365","category-microsoft-teams","category-office-365","tag-microsoft-365","tag-microsoft-teams","tag-office-365","tag-teams"],"_links":{"self":[{"href":"https:\/\/modern-workplace.uk\/index.php?rest_route=\/wp\/v2\/posts\/2017","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/modern-workplace.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/modern-workplace.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/modern-workplace.uk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/modern-workplace.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2017"}],"version-history":[{"count":13,"href":"https:\/\/modern-workplace.uk\/index.php?rest_route=\/wp\/v2\/posts\/2017\/revisions"}],"predecessor-version":[{"id":2036,"href":"https:\/\/modern-workplace.uk\/index.php?rest_route=\/wp\/v2\/posts\/2017\/revisions\/2036"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/modern-workplace.uk\/index.php?rest_route=\/wp\/v2\/media\/2030"}],"wp:attachment":[{"href":"https:\/\/modern-workplace.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2017"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/modern-workplace.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2017"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/modern-workplace.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2017"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}