Untitled

 avatar
unknown
plain_text
12 days ago
1.1 kB
31
Indexable
$TeamsCacheFolder = "$env:AppData\Microsoft\Teams"

function Check-KillProgram
{
    param (
        [Parameter(Position=0,Mandatory=$true)]
            [string]$ProgramName
    )

        #Get current user's Session ID
        $SID = ( (Get-Process -PID $pid).SessionID )
        #Check for running Outlook with current Session ID
        $Processes = ( Get-Process | Where-Object { ($_.SI -eq $SID) -AND ($_.ProcessName -eq "$ProgramName") } )
        if ($Processes) {
            foreach ($process in $Processes) {
                Write-Host "$($Process.ProcessName) with ProcessID $($Process.Id) found running under current user. Attampting to kill process."
                $Process | Stop-Process
            }
        }
}



#Kill Teams
Check-KillProgram -ProgramName "Teams"

Write-Host "Checking if Teams cache exists."
if (!(Test-Path $TeamsCacheFolder)) {
    Write-Host "No such folder $TeamsCacheFolder" -ForegroundColor Red
    Exit
} else {
    Write-Host "Teams cache folder $TeamsCacheFolder found.  Attempting to delete."
    Remove-Item -Force -Recurse $TeamsCacheFolder
}
Editor is loading...
Leave a Comment