Powershell - Supprimer Teams sur l'ensemble des profils utilisateurs

Voici un petit script que je vous partage pour retirer sur un poste teams sur l'ensemble du poste.
function unInstallTeams($path) {
  $clientInstaller = "$($path)\Update.exe"
  
   try {
        $process = Start-Process -FilePath "$clientInstaller" -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" -ForegroundColor Yellow
$MachineWide = Get-WmiObject -Class Win32_Product | Where-Object{$_.Name -eq "Teams Machine-Wide Installer"}
$MachineWide.Uninstall()
# Remove Teams for Current Users
$localAppData = "$($env:LOCALAPPDATA)\Microsoft\Teams"
$programData = "$($env:ProgramData)\$($env:USERNAME)\Microsoft\Teams"
If (Test-Path "$($localAppData)\Current\Teams.exe") 
{
  unInstallTeams($localAppData)
    
}
elseif (Test-Path "$($programData)\Current\Teams.exe") {
  unInstallTeams($programData)
}
else {
  Write-Warning  "Teams installation not found"
}

Commentaires

Posts les plus consultés de ce blog

MRemoteNG - Voir les mots de passe dans l'application

Powershell - Utiliser les requêtes WMI

PowerShell - Utiliser NSIS (Nullsoft Scriptable Install System) pour simplifier l'usage des scripts PS1