Esempio di script di PowerShell-pulizia della distribuzione di Microsoft TeamsPowerShell Script Sample - Microsoft Teams deployment clean up

Questo script di PowerShell può essere sfruttato per la pulizia di Microsoft Teams da computer o utenti di destinazione.This PowerShell script can be leveraged for the cleanup of Microsoft Teams from target machines or users. Deve essere eseguito per ogni utente in un computer di destinazione.It should be executed for every user on a targeted machine.

Script di esempioSample script

This script allows you to uninstall the Microsoft Teams app and remove Teams directory for a user.
Use this script to clear the installed Microsoft Teams application. Run this PowerShell script for each user profile for which the Teams App was installed on a machine. After the PowerShell has executed on all user profiles, Teams can be redeployed.

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

    if (Test-Path -Path $TeamsUpdateExePath) {
        Write-Host "Uninstalling Teams process"

        # Uninstall app
        $proc = Start-Process -FilePath $TeamsUpdateExePath -ArgumentList "-uninstall -s" -PassThru
    if (Test-Path -Path $TeamsPath) {
        Write-Host "Deleting Teams directory"
        Remove-Item -Path $TeamsPath -Recurse
    Write-Error -ErrorRecord $_
    exit /b 1