This commit is contained in:
2022-03-24 17:26:29 -04:00
parent 923e162f1a
commit d68d46a8db
+27 -9
View File
@@ -1,10 +1,28 @@
## Stop all instances of Teams . 'C:\Users\dyoder\Documents\Emberkom\Data\Projects\development\management-scripts\Tools.ps1'
End-Process -Name "Teams" -Match -Force # Make sure Microsoft Teams is installed
If ( Test-Path "${Env:LocalAppData}\Microsoft\Teams\Update.exe" ) {
## Remove all cached content # Get all running Teams processes
$CacheDir = "${Env:LOCALAPPDATA}\Microsoft\Teams" $ProcessList = (Get-Process -Name 'teams' -ErrorAction SilentlyContinue)
If ( Test-Path $CacheDir ) {
LogMsg "Removing all cached data for Microsoft Teams" If ( $ProcessList ) {
Try { Remove-Item $CacheDir -Recurse -Force } LogMsg "Stopping Microsoft Teams"
Catch { LogErr $_.Exception.Message } Try { $ProcessStopped = $true ; $ProcessList | Stop-Process -Force }
} Else { LogMsg "Could not clear cached data for Microsoft Teams because the directory could not be found: ${CacheDir}" } Catch { LogErr $_.Exception.Message }
} Else { $ProcessStopped = $false }
# Remove all cached content
$CacheDir = "${Env:AppData}\Microsoft\Teams"
If ( Test-Path $CacheDir ) {
LogMsg "Removing all cached data for Microsoft Teams"
Try { Remove-Item $CacheDir -Recurse -Force }
Catch { LogErr $_.Exception.Message }
} Else { LogMsg "Could not clear cached data for Microsoft Teams because the directory could not be found: ${CacheDir}" }
# Restart Teams if we needed to close it before clearing the cache
If ( $ProcessStopped ) {
LogMsg "Starting Microsoft Teams"
Try { Start-Process "${Env:LocalAppData}\Microsoft\Teams\Update.exe" -ArgumentList "--processStart ""Teams.exe""" }
Catch { LogErr $_.Exception.Message }
}
} Else { LogMsg "Cannot clear cache for Microsoft Teams because it isn't installed" }