As Microsoft Teams evolves and the New Teams Client is broadly available and soon will be the default, we have to update our current machines and make sure the user only has one installation left on his computer. And of course, we want to do the installation of the new Teams client via Intune.
All about the new Teams, its new features and performance improvements you can read here: New Microsoft Teams – Microsoft Adoption
If you deploy new Computers, it's enough to change the default application in the Teams Admin Center. And if wait long enough, Office will make this transition for you.
Table of Contents
- PowerShell Script for Teams Classic Removal and New Client Installation
- Deploy new Teams via Intune
- Conclusion
PowerShell Script for Teams Classic Removal and New Client Installation
The installation process of the new Teams client is very simpel. Just download the bootstrap installer from Microsoft and deploy run it with the correct parameters to install it machine wide and willen.
However, it can happen that the "old" Client aka. Teams Classic remains on the computer. For that reason, I run a cleanup before running the new installer.
Cleanup Teams Classic
To address the uninstallation of the Teams Classic client, I created a PowerShell script that provides a systematic approach to uninstalling Microsoft Teams Classic from both machine-wide and user-specific installations.
The script navigates through user profiles, identifies existing installations, and removes them. It also handles the removal of folders and shortcuts associated with these Teams installations.
function Uninstall-TeamsClassic($TeamsPath) {
try {
$process = Start-Process -FilePath "$TeamsPath\Update.exe" -ArgumentList "--uninstall /s" -PassThru -Wait -ErrorAction STOP
if ($process.ExitCode -ne 0) {
Write-Error "Uninstallation failed with exit code $($process.ExitCode)."
}
}
catch {
Write-Error $_.Exception.Message
}
}
# Remove Teams Machine-Wide Installer
Write-Host "Removing Teams Machine-wide Installer"
## Get all subkeys and match the subkey that contains "Teams Machine-Wide Installer" DisplayName.
$MachineWide = Get-ItemProperty -Path $registryPath | Where-Object -Property DisplayName -eq "Teams Machine-Wide Installer"
if ($MachineWide) {
Start-Process -FilePath "msiexec.exe" -ArgumentList "/x ""$($MachineWide.PSChildName)"" /qn" -NoNewWindow -Wait
}
else {
Write-Host "Teams Machine-Wide Installer not found"
}
# Get all Users
$AllUsers = Get-ChildItem -Path "$($ENV:SystemDrive)\Users"
# Process all Users
foreach ($User in $AllUsers) {
Write-Host "Processing user: $($User.Name)"
# Locate installation folder
$localAppData = "$($ENV:SystemDrive)\Users\$($User.Name)\AppData\Local\Microsoft\Teams"
$programData = "$($env:ProgramData)\$($User.Name)\Microsoft\Teams"
if (Test-Path "$localAppData\Current\Teams.exe") {
Write-Host " Uninstall Teams for user $($User.Name)"
Uninstall-TeamsClassic -TeamsPath $localAppData
}
elseif (Test-Path "$programData\Current\Teams.exe") {
Write-Host " Uninstall Teams for user $($User.Name)"
Uninstall-TeamsClassic -TeamsPath $programData
}
else {
Write-Host " Teams installation not found for user $($User.Name)"
}
}
# Remove old Teams folders and icons
$TeamsFolder_old = "$($ENV:SystemDrive)\Users\*\AppData\Local\Microsoft\Teams"
$TeamsIcon_old = "$($ENV:SystemDrive)\Users\*\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Microsoft Teams*.lnk"
Get-Item $TeamsFolder_old | Remove-Item -Force -Recurse
Get-Item $TeamsIcon_old | Remove-Item -Force -Recurse
Code language: PowerShell (powershell)
Installing the New Teams
In comparison to the cleanup part this is very veeeeeeeeeeeeeeeeeery easy 😉
Just download the bootstrap.exe from Microsoft and call it with the Parameter -p
for a installation.
& '.\teamsbootstrapper.exe' -p
Code language: PowerShell (powershell)
Deploy new Teams via Intune
Now everything together ist the package you can download above.
To upload it to your Intune environment, follow these steps:
- Login to Intune
- Navigate to: Apps > Windows
- Click +Add
- Choose: Windows app (Win32)
- Upload the TeamsNew.intunewin
- Fill out at least the Name, Description and Publisher
- The Install and Uninstall command is:
- %SystemRoot%\sysnative\WindowsPowerShell\v1.0\powershell.exe -windowstyle hidden -executionpolicy bypass -command .\install.ps1
- %SystemRoot%\sysnative\WindowsPowerShell\v1.0\powershell.exe -windowstyle hidden -executionpolicy bypass -command .\uninstall.ps1
- Install behavior: system
- In the Requirements choose:
Operating system architecture: 64-bit
Minimum OS: what suites you, if you don't have special requirements choose 2004 - In the Detection rules choose "Use a custom detection script" and upload the detection.ps1
- You can skip the next three steps Dependencies, Supersedence and Scope tags
- In the Assigments add your desired groups and your good to go.
Conclusion
In summary, transitioning to the new Microsoft Teams client is made seamless with the provided PowerShell script and Intune deployment. The cleanup process ensures the removal of the old Teams Classic client, leaving a clean slate for installation.
Thank you very much for this Script
BUT what Detection Script did you
use ?
I can not find the detection.ps1 ?
Hi, it's in the package on Github.
Here is the direct link: https://github.com/FlorianSLZ/scloud/blob/main/Program%20-%20win32/Microsoft%20Teams%20(new)/detection.ps1
Hi Florian,
maaaaaaaaaaaaaany THANX 🙂
You are my personal Christmas Hero 2023 !
Love to hear that and happy late Xmas 🥳
I've uploaded the intunewin app to Intune, added the install & uninstall commands, along with your detection script. However, the new Teams client never shows up on any device this is ran on. The classic client is removed but nothing shows up on the machine for the new, any ideas?
do you see anything in thel log?
The bootstrapinstaller should write a JSON respond in the logfile with an error code.
Hi Florian
This is exactly what I have been looking for! Thank you. One question though, is it possible to put a shortcut on the desktop or directly on the Task Bar (using intune) for the New Teams App? Our users are not very computer literate and they like to launch things directly from the desktop. We did have a shortcut for the 'old' Teams but not sure how to add it for the New Teams.
Once again, thank you so much for this information.
Hi Lorna, yes you absulutly can.
For example you can add the following after the installation to create a shortcut on the Public Desktop:
$WScriptShell = New-Object -ComObject WScript.Shell
$Shortcut = $WScriptShell.CreateShortcut("C:\Users\Public\Desktop\Teams.lnk")
$Shortcut.Arguments="shell:AppsFolder\MSTeams_8wekyb3d8bbwe!MSTeams"
$Shortcut.TargetPath = "shell:AppsFolder\MSTeams_8wekyb3d8bbwe!MSTeams"
$Shortcut.Save()
Hello Florian
Thank you for the help. this helped me to create the Desktop shortcut for all users successfully but get into one issue after the shortcut had been created and tried to double-click on the team's icon placed on the desktop to open Teams it would open I tried to check in task manager but it won't even show me any team process. also when I go to start and tried to open teams from there it working well but the desktop icon won't do anything
I dug a little deeper and it seems that the shortcut only works when created from the user's perspective.
I've put together a small blog about it: https://scloud.work/create-desktop-shortcuts-for-windows-apps/
(and it's being tested with Teams).
Moin Florian und danke für das Script! Wir haben das auf unseren Clients rausgerollt und alle Clients vermelden auch "installed" in Intune. Im Nachgang haben wir allerdings festgestellt, dass zwar das alte Teams runtergeschmissen wird und das neue installiert, das gilt aber auf den Rechnern wohl nur für den aktuell angemeldeten User. Wir haben uns mit anderen Benutzern auf diesen Rechnern angemeldet, dort wird New Teams nicht angezeigt. Es ist wohl aber dennoch unter Program Files\WindowsApps installiert. Komische Sache. Wir haben das System dahinter noch nicht herausgefunden und versuchen das Problem nun zu behandeln. Danke Microsoft! 🙂
Kleine Ergänzung: Das alte Teams ist komplett entfernt vom Client, soweit so gut. New Teams ist nur bei dem ersten User installiert, der sich am Client angemeldet hat. Danach vermeldet Intune korrekte Installation. Bei allen anderen Usern sieht man nach Anmeldung das New Teams weder in der Programmliste, noch bei den installierten Apps (Settings/Apps). in Appdata\Local\Packages ist kein MSTeams Ordner vorhanden. Auf Program Files\WindowsApps haben wir keinen Zugriff. Offenbar ist der einzige Weg, teamsbootstrapper.exe in jedem Profil einmal auszuführen...
Thanks for the great info!
The Shortcut part doesn't seem to work for me in the Public\Desktop location, it all looks good and has the icon but clicking it does absolutely nothing. Creating a new one based off the Run > shell:AppsFolder style that places it in your own Desktop does work and looks identical to the one we've just created in the Public Desktop, so not sure.... Does the PC need a reboot to have the app registered at the level the Public Desktop link is trying to access it at or something?
love the detection script, just wanted to check as even though it's really for the intune app detection can it be used in remediation script so I can silently swipe along machines to detect if they have classic still installed and then just remove classic using your cleanup script. did a quick test on just my machine as I had classic and new teams installed so wanted to check no damage for users if I double checked with remediation. I know probably answered my own question but always good to double check.
Yes, that for sure workd 🙂
Wow super
Works very nicely. I will tell though that for me, the boostrapper caused issues if i used it with MDT, tried several ways to remotely install it and did not work., commands run fine when used locally be it network or local folder
in the End , i found another forum where i could pass a powershell script as an App to install the new teams .MSIX with if anybody wants it
1. MDT -create a new app "Application without source files or elsewhere
powershell.exe -executionpolicy bypass -noprofile -noninteractive -file ".\InstallTeams64MSIX.ps1 (name your file like you want
Working directory: %Scriptroot%
2. Do go and create the powershell and save it in your script directory for MDT
Add-AppPackage -path "\\%yourmdtnameserber%\deploymentshare$\Applications\Microsoft Teams 64\MSTeams-x64.msix"
3. Dont forget to create a folder in your Applications folder and drop your MSIX in there to call it, or you could also xcopy it to the remote computer and execute locally (change the path accordingly)
Now i can deploy to specific machines instead of running a PS1 in the task sequence and it installs for everyone without prompt
Hi, can I ask you what installer you used to create TeamsNew.intunewin and if I could create this file with the current client version and then use the rest of your stuff.
Thanks for the answer and for your tutorials.
To create a new intunewin file you can follow these steps: https://scloud.work/win32-app-intunewin/
https://gregramsey.net/2012/02/20/win32_product-is-evil/
Don't use Win32_Product, just call MSIEXEC directly with the known ProductCode.
Thanks for your input and github request. It's now updated on the booth pages 🙂
How do you use the cleanup teams classic script ? Create an Intune platform script and send it to all devices after installing the new Teams app ? Other suggestions to do this company wide ? I am installing the new Teams app for some pilotusers. Currently all Teams clients were installed with machine wide isntaller and a update policy was created in Teams admin center with the pilot users., so the get the new upgrade automatically.
You can send this package to your pilot group. If the new team is already installed at that point, only the clienup will happen. If not, the upgrade is immediate.
How Can I add this PS uninstall classic teams? Can it be added on itune?
Kindly advise.
Uploading the install.intunewin uploads all files including the uninstall file.
Hi,
If I want only the Classic Teams uninstall, should I also upload all files including the files needed for the new Teams installation?
Thank You in advance
In this case you can delete the installation part and the bootstrap exe.
would it be possible to have a detection script for sccm application deployment ?
I don't do a lot of CM stuff, sorry, but you could create a custom registry key that you can look up in CM.
Heya, thanks so much for this script. I just have a question. It doesnt seem to uninstall the Machine Wide Installer and when running the line on its own
$MachineWide = Get-ItemProperty -Path $registryPath | Where-Object -Property DisplayName -eq "Teams Machine-Wide Installer"
It fails with
Get-ItemProperty : Cannot bind argument to parameter 'Path' because it is null.
At line:1 char:39
So the -Path $registryPath variable, where should that be declared and with what?
thanks
Kieren
$registryPath = "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*"
Source:https://github.com/FlorianSLZ/scloud/blob/main/Program%20-%20win32/Microsoft%20Teams%20(new)/install.ps1
Ahh, found it in the Install script. thanks again
Yes where is the $registryPath declared ?
Hi all,
We want to uninstall the Teams Classic via Intune. We created a detection and a remediation script. The remediation script set to using the system credential, but it is not working. The remediation shows that the script was finished successfully, but the Teams Classic and the Teams Machine-Wide Installer stayed on the devices without touch. Has anyone here run this uninstall script with Intune and succeeded?
Hi Florian this is a good script however it doesn't remove all registry entried which means it still shows in defender. I've added the following to the uninstall script and it is now no longer showing:
# Define the folder path to remove
$folderPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Teams"
# Get all user profiles
$userProfiles = Get-WmiObject Win32_UserProfile
foreach ($profile in $userProfiles) {
$sid = $profile.SID
$userFolderPath = "registry::HKEY_USERS\$sid\$folderPath"
# Check if the folder exists
if (Test-Path -Path $userFolderPath) {
# Remove the folder
Remove-Item -Path $userFolderPath -Recurse -Force
Write-Host "Removed folder: $userFolderPath"
} else {
Write-Host "Folder $userFolderPath does not exist."
}
}
Hi, may I know the powershell script or setup file that you use to generate the TeamsNew.intunewin ?
This is the classic way to create an Intunewin.
I've described the process here: https://scloud.work/win32-app-intunewin/