пятница, 30 октября 2020 г.

Удаление Microsoft Teams у пользователя (Microsoft Teams uninstall)

Удаление Microsoft Teams у пользователя с помощью Powershell

 

Код скрипта

<#
.SYNOPSIS
This script allows you to uninstall the Microsoft Teams app and remove Teams directory for a user.
.DESCRIPTION
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.
#>
Write-Host "Don't worry"
$TeamsPathLocal = [System.IO.Path]::Combine($env:LOCALAPPDATA, 'Microsoft', 'Teams')
##$TeamsPathRoaming = [System.IO.Path]::Combine($env:APPDATA, 'Microsoft', 'Teams')
$TeamsUpdateExePath = [System.IO.Path]::Combine($env:LOCALAPPDATA, 'Microsoft', 'Teams', 'Update.exe')
$DesktopPath = [Environment]::GetFolderPath("Desktop")

try
{
Write-Host "Microsoft Teams installed and we try to uninstall it"
Start-Sleep 1

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

        # Uninstall app
        $proc = Start-Process -FilePath $TeamsUpdateExePath -ArgumentList "-uninstall -s" -PassThru
        $proc.WaitForExit()
    }
    Start-Sleep 1
    
    if (Test-Path -Path $TeamsPathLocal) {
        Write-Host "Deleting Teams directory"
        Remove-Item -Path $TeamsPathLocal -Recurse                    
    }   

    If (Test-Path "$DesktopPath\Microsoft Teams.lnk"){
    Write-Host "Deleting Teams desktop link"
    Remove-Item "$DesktopPath\Microsoft Teams.lnk"
    }
    Start-Sleep 5
}
catch
{
    Write-Error -ErrorRecord $_
    Start-Sleep 15
    exit /b 1
}

 


Комментариев нет:

Отправить комментарий

Пользователи и права на каталоги в Linux

Создаём пользователя системы и меняем права на каталоги, с коротким описанием