Skip to main content

Microsoft Teams - Full Removal Script

This page documents a comprehensive PowerShell script to completely uninstall Microsoft Teams from all user profiles, including registry, file system remnants, and WMI entries.


πŸ“‹ Purpose

  • Stop all running Teams processes

  • Uninstall Teams for all users (WMI + user installs)

  • Remove leftover Teams folders and desktop/start menu shortcuts

  • Clean registry keys (HKLM, HKU)

  • Remove orphaned installer folders

πŸ› οΈ Script
Write-Output "Stopping Teams processes"
Get-Process "*teams*" | Stop-Process -ErrorAction SilentlyContinue


Write-Host "Removing All Teams Installations via WMI"
Get-WmiObject -Class Win32_Product | Where-Object{$_.Name -match "Teams"} | ForEach-Object {$_.Uninstall()}

Write-Output "Checking all users for Teams installs"
$TeamsUsers = Get-ChildItem -Path "$($ENV:SystemDrive)\Users"
 $TeamsUsers | ForEach-Object {
    Try { 
		Write-Output ($_.Name)
        if (Test-Path "$($ENV:SystemDrive)\Users\$($_.Name)\AppData\Local\Microsoft\Teams") {
			Write-Output "  Teams install found...Uninstalling"
            Start-Process -FilePath "$($ENV:SystemDrive)\Users\$($_.Name)\AppData\Local\Microsoft\Teams\Update.exe" -ArgumentList "-uninstall -s" -Wait
        }
    } Catch { 
        Write-Output "  Failed to uninstall from - $($ENV:SystemDrive)\Users\$($_.Name)\AppData\Local\Microsoft\Teams\Update.exe"
    }
	
	Try {
		if (Test-Path "$($ENV:SystemDrive)\Users\$($_.Name)\AppData\Local\Microsoft\Teams") {
			Write-Output "  Cleaning up orphaned Teams install folder"
			Remove-Item –Path "$($ENV:SystemDrive)\Users\$($_.Name)\AppData\Local\Microsoft\Teams" -Recurse -Force -ErrorAction Ignore
		}
    } Catch {
        Write-Output "  Failed to remove - $($ENV:SystemDrive)\Users\$($_.Name)\AppData\Local\Microsoft\Teams"
    }
	Write-Output "  Removing orphaned desktop link"
	Remove-Item "$($ENV:SystemDrive)\Users\$($_.Name)\Desktop\Microsoft Teams.lnk" -ErrorAction SilentlyContinue
	
	Write-Output "  Removing orphaned start menu link"
	Remove-Item "$($ENV:SystemDrive)\Users\$($_.Name)\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Microsoft Teams.lnk" -ErrorAction SilentlyContinue
}


Write-Output ""
Write-Output ""
Write-Output "Searching HKLM for Teams remnants"
$prouctNameToPurge = "Teams"
$RegPath = "HKLM:\Software\Classes\Installer\Products\"
Write-Output("  Clean registry " + $RegPath)
$appRegKey = Get-ChildItem -Path $RegPath -Recurse | Get-ItemProperty | Where-Object {$_.ProductName -match $prouctNameToPurge}
If($appRegKey.PSChildName){
	foreach($appKey in $appRegKey.PSChildName){
		if($appKey -ne ""){
			$appDirToDelete = $RegPath + $appKey
			SetLog(("App registry to delete:" + $appDirToDelete))
			Remove-Item -Path $appDirToDelete -Force -Recurse -ErrorAction SilentlyContinue 
			If(Test-Path $appDirToDelete){
				Write-Output("  Failed to delete " + $appDirToDelete)
			}else{
				Write-Output("  Successfully deleted " + $appDirToDelete)
			}
		}
	}
}else{
	Write-Output("  No "+ $prouctNameToPurge +" registry keys found in " + $RegPath)
}


$RegPaths = @("HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\","HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\")
foreach($RegPath in $RegPaths){
    Write-Output("  Clean registry " + $RegPath)
    $appRegKey = Get-ChildItem -Path $RegPath -Recurse | Get-ItemProperty | Where-Object {$_.DisplayName -match $prouctNameToPurge}
    If($appRegKey.PSChildName){
        foreach($appKey in $appRegKey.PSChildName){
            if($appKey -ne ""){
                $appDirToDelete = $RegPath + $appKey
                Write-Output("  " + $prouctNameToPurge + " registry to delete:" + $appDirToDelete)
                Remove-Item -Path $appDirToDelete -Force -Recurse -ErrorAction SilentlyContinue 
                If(Test-Path $appDirToDelete){
                    Write-Output("  Failed to delete " + $appDirToDelete)
                }else{
                    Write-Output("  Successfully deleted " + $appDirToDelete)
                }
            }
        }
    }else{
        Write-output ("  No "+ $prouctNameToPurge +" registry keys found in " + $RegPath)
    }
}



Write-Output ""
Write-Output ""
Write-Output "Searching HKU for Teams remnants"
$RegPaths = @("\Software\Microsoft\Windows\CurrentVersion\Uninstall\","\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\")
New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS -ErrorAction SilentlyContinue
$allHKU = Get-ChildItem HKU:
foreach($HKU in $allHKU){
    foreach($RegPath in $RegPaths){
		$appRegKey = Get-ChildItem -Path ('HKU:\' + ($HKU.PSChildName) + $RegPath ) -Recurse -ErrorAction SilentlyContinue| Get-ItemProperty | Where-Object {$_.DisplayName -match $prouctNameToPurge}
        if($appRegKey.QuietUninstallString){
			$uninstSting = ($appRegKey.QuietUninstallString -split '"')[1]
			Start-Process $uninstSting -ArgumentList "--uninstall -s" -Wait -ErrorAction SilentlyContinue
            Remove-Item -Path ('HKU:\' + ($HKU.PSChildName) + $RegPath + ($appRegKey.PSChildname) ) -ErrorAction SilentlyContinue
        }
    }
     Remove-Item -Path ('HKU:\' + ($HKU.PSChildName) + '\SOFTWARE\Microsoft\Office\Teams') -ErrorAction SilentlyContinue
}
Write-Output ""
Write-Output ""
Write-Output "Cleaning Teams Installer Folder"
Remove-Item "$($ENV:SystemDrive)\Program Files (x86)\Teams Installer" -Recurse -Force -ErrorAction Ignore

πŸ“Ž Notes

  • Run with Administrator rights.

  • Designed to fully remove Teams from shared workstations or persistent VDI environments.

  • Use caution when applying to multi-user systems.

  • Logs or error handling can be added with Start-Transcript or logging functions.