Skip to content

Latest commit

 

History

History
64 lines (53 loc) · 1.84 KB

powershell-script-deployment-cleanup.md

File metadata and controls

64 lines (53 loc) · 1.84 KB
title author ms.author manager ms.topic ms.reviewer ms.date ms.service audience description f1.keywords ms.localizationpriority search.appverid ROBOTS ms.collection appliesto
PowerShell script sample - Teams deployment cleanup
MicrosoftHeidi
heidip
jtremper
article
amitsri
10/16/2020
msteams
admin
Use this PowerShell script to uninstall Teams and remove the Teams folder for users.
NOCSH
medium
MET150
NOINDEX, NOFOLLOW
M365-collaboration
Microsoft Teams

PowerShell script sample - Teams deployment clean up

Use this script to remove Teams. This script uninstalls Teams and removes the Teams folder for a user. Run this script for each user profile in which Teams was installed on a computer.

Sample script

<#
.SYNOPSIS
This script uninstalls the Teams app and removes the Teams directory for a user.
.DESCRIPTION
Use this script to remove and clear the Teams app from a computer. Run this PowerShell script for each user profile in which Teams was installed on the computer. After you run this script for all user profiles, redeploy Teams.
#>

$TeamsPath = [System.IO.Path]::Combine($env:LOCALAPPDATA, 'Microsoft', 'Teams')
$TeamsUpdateExePath = [System.IO.Path]::Combine($TeamsPath, 'Update.exe')

try
{
    if ([System.IO.File]::Exists($TeamsUpdateExePath)) {
        Write-Host "Uninstalling Teams process"

        # Uninstall app
        $proc = Start-Process $TeamsUpdateExePath "-uninstall -s" -PassThru
        $proc.WaitForExit()
    }
    Write-Host "Deleting Teams directory"
    Remove-Item –path $TeamsPath -recurse
}
catch
{
    Write-Output "Uninstall failed with exception $_.exception.message"
    exit /b 1
}

Related topics