TeamsOnWVD.psm1
########## Teams for Windows Virtual Desktop # Author : Yannick Dils # Create Date : 07/07/2020 # Version : 2.3 ########## function install-teams64bit { <# .SYNOPSIS Allows you to install Teams on Windows Virtual Desktop .DESCRIPTION This function allows you to install the Microsoft Teams 64bit client on Windows Virtual Desktop including the required prerequisites to enable the necessary optimizations .EXAMPLE C:\PS>install-teams64bit .LINK https://www.tunecom.be/teams-on-windows-virtual-desktop-teamsonwvd-powershell-module/ #> #region step 1 - Import regkeys Write-Host "Step 1 : Checking the required registry keyssn" -ForegroundColor Cyan $KeyPath = "HKLM:\SOFTWARE\Microsoft\Teams\" $WVDKey = "IsWVDEnvironment" IF(!(Test-Path $KeyPath)) { Write-Host "The path does not exist, we will create this path now" -ForegroundColor red New-Item -Path $KeyPath -Force New-ItemProperty -Path $KeyPath -Name $WVDKey -PropertyType "DWORD" -Value "1" -Force } else { Write-Host "The path already exists, we don't need to create this path now" -ForegroundColor Green New-ItemProperty -Path $KeyPath -Name $WVDKey -PropertyType "DWORD" -Value "1" -Force } #endregion step 1 #region step 2.1 - Download the Teams WebSocket Service $WebSocketDownloadlink = "https://query.prod.cms.rt.microsoft.com/cms/api/am/binary/RE4yj0i" $TempDir = "C:\Temp" $OutputWebsocket = "C:\Temp\Teamswebsocket.msi" $Logfile = $TempDir + "\logfile.txt" $Path = Test-Path $TempDir If ($Path -eq $true) { Write-Host "Step 2.1 : The C:\Temp path already exists, no need to create one" -ForegroundColor Cyan } Else { Write-host "Step 2.1 : We are creating a temp directory C:\Temp" -ForegroundColor Cyan $DontShow = mkdir $TempDir } (New-Object System.Net.WebClient).DownloadFile($WebSocketDownloadlink, $OutputWebsocket) cd $TempDir #endregion step 2.1 #region step 2.2 - Download the Teams MSI Package #$DownloadLink.old1 = "https://statics.teams.cdn.office.net/production-windows-x64/1.3.00.4461/Teams_windows_x64.msi" $DownloadLink = "https://statics.teams.cdn.office.net/production-windows-x64/1.3.00.13565/Teams_windows_x64.msi" $TempDir = "C:\Temp" $OutputTeams = "C:\Temp\teams64.msi" $Logfile = $TempDir + "\logfile.txt" $Path = Test-Path $TempDir If ($Path -eq $true) { Write-Host "Step 2.2 : The C:\Temp path already exists, no need to create one" -ForegroundColor Cyan } Else { Write-host "Step 2.2 : We are creating a temp directory C:\Temp" -ForegroundColor Cyan $DontShow = mkdir $TempDir } (New-Object System.Net.WebClient).DownloadFile($DownloadLink, $OutputTeams) cd $TempDir #endregion step 2 #region step 3.1 - Install Teams Websocket Services Write-Host "Step 3.1 : Let us install Teams WebSocketServices" -ForegroundColor Cyan msiexec /passive /a $OutputWebsocket /l*v $Logfile ALLUSER=1 ALLUSERS=1 #endregion step 3.2 #region step 3.2 - Install Teams MSI Write-Host "Step 3.2 : Let us install Teams" -ForegroundColor Cyan msiexec /i $OutputTeams /l*v $Logfile ALLUSER=1 ALLUSERS=1 #endregion step 3 } function install-teams32bit { <# .SYNOPSIS Allows you to install Teams on Windows Virtual Desktop .DESCRIPTION This function allows you to install the Microsoft Teams 32bit client on Windows Virtual Desktop including the required prerequisites to enable the necessary optimizations .EXAMPLE C:\PS>install-teams32bit .LINK https://www.tunecom.be/teams-on-windows-virtual-desktop-teamsonwvd-powershell-module/ #> #region step 1 - import regkeys Write-Host "Step 1 : Let us first set a couple of registry keysn" -ForegroundColor Cyan $KeyPath = "HKLM:\SOFTWARE\Microsoft\Teams\" $WVDKey = "IsWVDEnvironment" IF(!(Test-Path $KeyPath)) { Write-Host "The path does not exist, we will create this path now" -ForegroundColor red New-Item -Path $KeyPath -Force New-ItemProperty -Path $KeyPath -Name $WVDKey -PropertyType "DWORD" -Value "1" -Force } else { Write-Host "The path already exists, we don't need to create this path now" -ForegroundColor Green New-ItemProperty -Path $KeyPath -Name "$WVDKey" -PropertyType "DWORD" -Value "1" -Force } #endregion step 1 #region step 2.1 - Download the Teams WebSocket Service $WebSocketDownloadlink = "https://query.prod.cms.rt.microsoft.com/cms/api/am/binary/RE4yj0i" $TempDir = "C:\Temp" $OutputWebsocket = "C:\Temp\Teamswebsocket.msi" $Logfile = $TempDir + "\logfile.txt" $Path = Test-Path $TempDir If ($Path -eq $true) { Write-Host "Step 2.1 : The C:\Temp path already exists, no need to create one" -ForegroundColor Cyan } Else { Write-host "Step 2.1 : We are creating a temp directory C:\Temp" -ForegroundColor Cyan $DontShow = mkdir $TempDir } (New-Object System.Net.WebClient).DownloadFile($WebSocketDownloadlink, $OutputWebsocket) cd $TempDir #endregion step 2.1 #region step 2.2 - Download the Teams MSI Package #$DownloadLink.old = "https://statics.teams.cdn.office.net/production-windows/1.3.00.4461/Teams_windows.msi" $DownloadLink = "https://statics.teams.cdn.office.net/production-windows/1.3.00.13565/Teams_windows.msi" $TempDir = "C:\Temp" $Output = "C:\Temp\teams32.msi" $Logfile = $TempDir + "\logfile.txt" $Path = Test-Path $TempDir If ($Path -eq $true) { Write-Host "Step 2.2 : The C:\Temp path already exists, no need to create one" -ForegroundColor Cyan } Else { Write-host "Step 2.2 : We are creating a temp directory C:\Temp" -ForegroundColor Cyan $DontShow = mkdir $TempDir } (New-Object System.Net.WebClient).DownloadFile($DownloadLink, $output) cd $TempDir #endregion step 2 #region step 3.1 - Install Teams Websocket Services Write-Host "Step 3.1 : Let us install Teams WebSocketServices" -ForegroundColor Cyan msiexec /passive /a $OutputWebsocket /l*v $Logfile ALLUSER=1 ALLUSERS=1 #endregion step 3.2 #region step 3 - Install Teams MSI Write-Host "Step 3 : Let us install Teams" -ForegroundColor Cyan msiexec /i $Output /l*v $Logfile ALLUSER=1 ALLUSERS=1 #endregion step 3 } function remove-teams64bit { <# .SYNOPSIS Allows you to un-install Teams on Windows Virtual Desktop .DESCRIPTION This function allows you to un-install the Microsoft Teams client on Windows Virtual Desktop including the required prerequisites to enable the necessary optimizations .EXAMPLE C:\PS>remove-teams64bit .LINK https://www.tunecom.be/teams-on-windows-virtual-desktop-teamsonwvd-powershell-module/ #> #region step 1 - Teams Per User Uninstall Write-Host "Step 1 : Let us un-install Teams per user base" -ForegroundColor Cyan Get-WmiObject -Class Win32_Product | Where-Object {$_.IdentifyingNumber -eq "{39AF0813-FA7B-4860-ADBE-93B9B214B914}"} | Remove-WmiObject $ListUsers = Get-ChildItem -Path "$($ENV:SystemDrive)\Users" $ListUsers | ForEach-Object { Try { if (Test-Path "$($ENV:SystemDrive)\Users\$($_.Name)\AppData\Local\Microsoft\Teams") { Start-Process -FilePath "$($ENV:SystemDrive)\Users\$($_.Name)\AppData\Local\Microsoft\Teams\Update.exe" -ArgumentList "-uninstall -s" } } Catch { Out-Null } } $ListUsers | ForEach-Object { Try { if (Test-Path "$($ENV:SystemDrive)\Users\$($_.Name)\AppData\Local\Microsoft\Teams") { Remove-Item –Path "$($ENV:SystemDrive)\Users\$($_.Name)\AppData\Local\Microsoft\Teams" -Recurse -Force -ErrorAction Ignore } } Catch { Out-Null } } #endregion step 1 #region step 2 - Teams Machine Wide Uninstall Write-Host "Step 2 : Let us un-install Teams per machine base" -ForegroundColor Cyan #get-wmiobject Win32_Product | Format-Table IdentifyingNumber, Name, LocalPackage -AutoSize $TeamsWMI = Get-WmiObject -Class Win32_Product | Where-Object {$_.Name -eq "Teams Machine-Wide Installer"} $TeamsGUID = $TeamsWMI.IdentifyingNumber MsiExec.exe /X$TeamsGUID /qn $TeamsWMI | Remove-WmiObject #endregion step 2 - Teams Machine Wide Uninstall #region step 3 - Remove regkeys Write-Host "Step 3 : Checking the required registry keyssn" -ForegroundColor Cyan $KeyPath = "HKLM:\SOFTWARE\Microsoft\Teams\" $WVDKey = "IsWVDEnvironment" IF(!(Test-Path $KeyPath)) { Write-Host "The path does not exist, we don't have to remove it" -ForegroundColor red } else { Write-Host "The path exists, we will remove it now" -ForegroundColor Green Remove-Item -Path $KeyPath -Force } #endregion step 3 } |