Deploy Teams media optimization with Intune Proactive Remediation to Windows 365

This post has been republished via RSS; it originally appeared at: Device Management in Microsoft articles.

The Microsoft Windows 365 provides all the benefits of Windows, without any of the traditional hardware limitations. It is the most optimized Microsoft 365 powered compute experience delivered from Azure and managed by Microsoft. It is Microsoft’s best expression of Windows and M365 and is always secure and up to date.

Teams media optimization package includes Remote Desktop WebRTC Redirector Service and latest Microsoft Visual C++ Redistributable. With media optimization for Microsoft Teams, Windows 365 can handle audio and video locally for Teams and meetings. Windows 365 can have all the benefits of the modern media stack including HW video decoding with the high-performance peer-to-peer streaming facilitated by media optimization WebRTC. This feature effectively solves some user meeting issues like sound echo which they can encounter during Teams meeting without media optimization. It also provided the same audio and video experience as users who are using physical PCs.

Teams media optimization package has been integrated into the latest Windows 365 OS with integrated office apps. Users may not see audio or video issues initially when they join meetings with Teams if they are using office apps integrated version Windows 365. The below process is still helpful for remediation if Teams functionality is broken in the office apps integrated version. Additionally, if the users didn’t purchase office apps integrated Windows 365 version and they want to install office apps later, the below process is also helpful for them to deploy Teams media optimization package from scratch.

 

Prerequisites

Before you can use media optimization in Windows 365, the below prerequisites need to be prepared:

  • Install the Windows Desktop Client on any Windows device which you use to connect to Windows 365.
  • Deploy Teams Machine-Wide Installer to Windows 365. Microsoft Teams Machine-Wide Installer is included as part of the new installation of Microsoft 365 Apps starting with version 1902.  For this step, you can use separate Teams installer or Microsoft 365 Apps deployment.
  • You must install Microsoft Teams machine-wide installer version 1.3.00.4461 or later – the 64-bit version is highly recommended.

Deploy Teams media optimization with Intune Proactive Remediation

Navigate to the Intune portal https://endpoint.microsoft.com -> Reports -> Endpoint Analytics -> Proactive Remediations. Proactive remediations are script packages that can detect and fix common support issues on the user’s device. It also can be used to deploy customized Powershell scripts to the user device.

In Teams media optimization deployment, if users have Teams installed in ($env:ProgramData)\$env:USERNAME\Microsoft\Teams or in ($env:LOCALAPPDATA)\Microsoft\Teams, we need to uninstall it at first before we install media optimization. Teams media optimization only will be working under the scenario when media optimization is installed before the user profile Teams installation.

 

Detection Script 

#===========================================================================

# Script Name:     detectMedia.ps1

# Description:     Detect if Team media optimization has been installed and if it is installed, make sure it is

#                  installed after user profile Teams installation. if it is not installed or installed after

#                  user profile Teams installation, we need to remove Teams at first before installing media optimization.

#==========================================================================

$TeamsMediaFile = "C:\Program Files\Remote Desktop WebRTC Redirector\MsRdcWebRTCSvc.exe"

$TeamsMediaPath = "C:\Program Files\Remote Desktop WebRTC Redirector"

$TeamMediaFileExist = Test-Path -Path $TeamsMediaFile

$folders = Get-ChildItem -Path C:\users -Directory -force -ErrorAction SilentlyContinue |select fullname,name

$totalFolders = $folders.Count + $folders.Count

if($TeamMediaFileExist -eq $true )

{

    foreach($eachfolder in $folders)

    {

        $TeamsPath = $eachfolder.Fullname + "\AppData\Local\Microsoft\Teams"

        $TeamsUpdateExePath = $TeamsPath + "\Update.exe"

        $TeamsUpdateExist = Test-Path -Path $TeamsUpdateExePath

        $TeamsPathExist = Test-Path -Path $TeamsPath

         if ( $TeamsUpdateExist -eq $True )

        {

            $TeamsCreationTime = get-date ( (get-item -path $TeamsPath).LastWriteTime)

            $TeamsMediaCreationTime = get-date ( (get-item -path $TeamsMediaPath).CreationTime)

            if( $TeamsMediaCreationTime -lt $TeamsCreationTime)

            {

                $totalFolders = $totalFolders -1

            }

          }

        elseif( $TeamsPathExist -eq $false)

        {

           $totalFolders = $totalFolders -1

        } 

        $TeamsUserPath = "C:\ProgramData\" + $eachfolder.name + "\Microsoft\Teams"

        $TeamsUserUpdateExePath = $TeamsUserPath + "\Update.exe"

        $TeamsUserUpdateExist = Test-Path -Path $TeamsUserUpdateExePath

        $TeamsUserPathExist = Test-Path -Path $TeamsUserPath    

        if ( $TeamsUserUpdateExist -eq $True )

        {

            $TeamsCreationTime = get-date ( (get-item -path $TeamsUserPath).LastWriteTime)

            $TeamsMediaCreationTime = get-date ( (get-item -path $TeamsMediaPath).CreationTime)

            if( $TeamsMediaCreationTime -lt $TeamsCreationTime)

            {

                $totalFolders = $totalFolders -1

            }

        }

        elseif($TeamsUserPathExist -eq $false)

        {

            $totalFolders = $totalFolders - 1

        } 

    }

    $TeamsReg = "HKCU:\Software\Microsoft\Office\Teams"

#if this registry key is existing, it will block user profile Teams installation by Teams machine-wide installer.

    $TeamRegExist = test-path -path $TeamsReg

    if($TeamRegExist -eq $True)

    {

         $PreventInstallStateKey = Get-Item -Path $TeamsReg

         $preventInstall = $PreventInstallStateKey.GetValue("PreventInstallationFromMsi")

       }

    else { $preventInstall = $null}

 if(($totalFolders -eq 0) -and ($preventInstall -eq $null))     { write-host "Compliant"  exit 0}

else {

write-host “Not Compliant”

exit 1

}

}

else {

  write-host “Not Compliant”

  exit 1

}

 

Remediation Script 

#=========================================================================== 

# Script Name:     UninstallTeams_InstallMediaOptimization.ps1 

# Description:     Uninstall user profile Teams and Install Teams media #optimizatio. 

#========================================================================== 

 $folders = Get-ChildItem -Path C:\users -Directory -force -ErrorAction SilentlyContinue |select fullname,name 

 $TeamsReg = "HKCU:\Software\Microsoft\Office\Teams" 

 $TeamRegExist = test-path -path $TeamsReg 

 try 

{ 

    foreach($eachfolder in $folders) 

    { 

        $TeamsPath = $eachfolder.Fullname + "\AppData\Local\Microsoft\Teams" 

        $TeamsUpdateExePath = $TeamsPath + "\Update.exe" 

        $TeamsUserPath = "C:\ProgramData\" + $eachfolder.name + "\Microsoft\Teams" 

        $TeamsUserUpdateExePath = $TeamsUserPath + "\Update.exe" 

         if (Test-Path -Path $TeamsUpdateExePath)  

        { 

            Write-Host "Uninstalling Teams process" 

             # Uninstall Teams from user profile  

            $proc = Start-Process -FilePath $TeamsUpdateExePath -ArgumentList "-uninstall -s" -PassThru 

            $proc.WaitForExit() 

        } 

        if (Test-Path -Path $TeamsPath) { 

            Write-Host "Deleting Teams directory" 

            Remove-Item –Path $TeamsPath -Recurse 

        } 

         if (Test-Path -Path $TeamsUserUpdateExePath)  

        { 

            Write-Host "Uninstalling Teams process in ProgramData folder" 

             # Uninstall Teams from programdata folder 

            $proc = Start-Process -FilePath $TeamsUserUpdateExePath -ArgumentList "-uninstall -s" -PassThru 

            $proc.WaitForExit() 

        } 

        if (Test-Path -Path $TeamsUserPath) { 

            Write-Host "Deleting Teams directory" 

            Remove-Item –Path $TeamsUserPath -Recurse 

        } 

     } 

    # if this Teams preventinstallationFromMsi is existing, remove it to make user profile Teams installation  

    # be triggered by Teams machine-wide installer 

    if($TeamRegExist -eq $True) 

    { 

         $PreventInstallStateKey = Get-Item -Path $TeamsReg 

         $preventInstall = $PreventInstallStateKey.GetValue("PreventInstallationFromMsi")  

         if ($preventInstall -ne $null) 

         { 

            Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Office\Teams" -Name "PreventInstallationFromMsi" 

         }  

    } 

    #Install Teams media optimization 

    #Create a directory to save download files 

    $tempCreated = $false 

    if (!(Test-Path C:\temp)) { 

        New-Item -Path C:\ -ItemType Directory -Name temp 

         $tempCreated = $true 

    } 

     # Add registry Key 

    reg add "HKLM\SOFTWARE\Microsoft\Teams" /v IsWVDEnvironment /t REG_DWORD /d 1 /f /reg:64 

     #Download C++ Runtime 

    invoke-WebRequest -Uri https://aka.ms/vs/16/release/vc_redist.x64.exe -OutFile "C:\temp\vc_redist.x64.exe" 

     #Download WebRTC 

    invoke-WebRequest -Uri https://query.prod.cms.rt.microsoft.com/cms/api/am/binary/RE4AQBt -OutFile "C:\temp\MsRdcWebRTCSvc_HostSetup_1.0.2006.11001_x64.msi" 

     #Install C++ runtime 

   Start-Process "C:\temp\vc_redist.x64.exe" -ArgumentList @('/q', '/norestart') -NoNewWindow -Wait -PassThru 

     #Install MSRDCWEBTRCSVC 

    Start-Process msiexec.exe -ArgumentList '/i C:\temp\MsRdcWebRTCSvc_HostSetup_1.0.2006.11001_x64.msi /q /n' -Wait  

 

    if ($tempCreated) { 

        #Remove temp folder 

        Remove-Item -Path C:\temp\ -Recurse 

    } 

    else { 

        #Remove downloaded C++ Runtime file 

        Remove-Item -Path C:\temp\vc_redist.x64.exe 

         #Remove downloaded WebRTC file 

        Remove-Item -Path C:\temp\MsRdcWebRTCSvc_HostSetup_1.0.2006.11001_x64.msi 

    } 

         Write-host "Media Optimization Installed" 

        exit 0 

 } 

 catch 

 { 

        Write-Error -ErrorRecord $_ 

        exit /b 1 

 } 

  

Verify and test the media optimization 

  • After the above remediation script has been run successfully in Windows 365, users should log in to their Windows 365. Teams per user installation will be triggered automatically by Teams machine-wide installer. After the Teams pops up, go to Teams user profile, click “About”, choose “Version”, below “WVD Media Optimized” should be displayed.

ClaudiaZH2021_0-1639699800911.png

  

ClaudiaZH2021_1-1639699800915.png

 

  • Go to Teams user profile, click “Settings”, choose “Devices”, you should see “Audio devices” is set to “Custom Setup”. Speaker, Microphone, and Camera available locally will be enumerated in the device menu as the below screenshot. If the menu shows “Remote Audio”, please sign out and sign in to try again. 

 ClaudiaZH2021_2-1639699800917.png

 

  • If above verifications are done, you can use Teams in Windows 365 with local audio and video to participate in meetings. The performance of the audio and video quality will be the same as when you are using Teams in your physical PC. 

Troubleshooting 

If users don’t see media optimization as in the above screenshots or Teams doesn’t automatically start after users log in Windows 365: 

  • Check if below registry key has been created in Windows 365: 

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Teams\ 

Name: IsWVDEnvironment 
Type: REG_DWORD 
Value: 1 

  • Check if media optimization and Teams machine-wide installer have been installed in Windows 365: 

ClaudiaZH2021_3-1639699800921.png

 

  • Check SquirrelSetup.log in %LocalAppData%\SquirrelTemp. The system automatically starts Teams when a user logs in if Teams machine-wide installer is healthy in the device. If the Teams doesn’t start after user logs in, all the failures about Teams installation and updates are recorded in SquirrelSetup.log. 

ClaudiaZH2021_4-1639699800934.png

Note: This script/function is provided AS IS without warranty of any kind. Author(s) disclaim all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall author(s) be held liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the script or documentation.

 

REMEMBER: these articles are REPUBLISHED. Your best bet to get a reply is to follow the link at the top of the post to the ORIGINAL post! BUT you're more than welcome to start discussions here:

This site uses Akismet to reduce spam. Learn how your comment data is processed.