feat: arrêt des processus Teams (classic)
Stoppe les processus Teams classic en exécution Reprise du snippet présenté sur https://stackoverflow.com/a/28482050
This commit is contained in:
parent
e357da5802
commit
78691ec810
@ -1,9 +1,31 @@
|
|||||||
|
# Clean Microsoft Teams Cache after stopping process
|
||||||
|
|
||||||
$SamAccountName = Read-Host -Prompt "SamAccountName"
|
$SamAccountName = Read-Host -Prompt "SamAccountName"
|
||||||
|
|
||||||
$BasePath = "C:\Users"
|
$BasePath = "C:\Users"
|
||||||
|
$FoldersToDelete = @("$BasePath\$SamAccountName\AppData\Roaming\Teams","$BasePath\$SamAccountName\AppData\Roaming\Microsoft\Teams","$BasePath\$SamAccountName\AppData\Local\Packages\Microsoft.AAD.BrokerPlugin_cw5n1h2txyewy","$BasePath\$SamAccountName\AppData\Local\Microsoft\OneAuth","$BasePath\$SamAccountName\AppData\Local\Microsoft\IdentityCache")
|
||||||
|
|
||||||
$FoldersToDelete = @("$BasePath\$SamAccountName\AppData\Roaming\Teams","$BasePath\$SamAccountName\AppData\Roaming\Microsoft\Teams","$BasePath\$SamAccountName\AppData\Local\Packages\Microsoft.AAD.BrokerPlugin_cw5n1h2txyewy","$BasePath\$SamAccountName\AppData\Local\Microsoft\OneAuth","$BasePath\$SamAccountName\AppData\Local\Microsoft\IdentityCache")
|
Function Stop-MSTeams {
|
||||||
|
$MSTeamsProcessList = Get-Process -Name "Teams" -ErrorAction SilentlyContinue | Where-Object {($_.Description -eq "Microsoft Teams") -and ($_.Company -eq "Microsoft Corporation")}
|
||||||
|
if ($MSTeamsProcessList) {
|
||||||
|
# try gracefully first
|
||||||
|
$MSTeamsProcessList.CloseMainWindow()
|
||||||
|
# kill after five seconds
|
||||||
|
Sleep 5
|
||||||
|
if (-not $MSTeamsProcessList.HasExited) {
|
||||||
|
$MSTeamsProcessList |
|
||||||
|
Stop-Process -Force
|
||||||
|
}
|
||||||
|
}
|
||||||
|
# Source : https://stackoverflow.com/a/28482050
|
||||||
|
|
||||||
foreach ($IndividualFolder in $FoldersToDelete) {
|
|
||||||
Remove-Item -Recurse -Force -Path $IndividualFolder
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Function Remove-MSTeamsCacheDirectory {
|
||||||
|
foreach ($IndividualFolder in $FoldersToDelete) {
|
||||||
|
Write-Host Remove-Item -Recurse -Force -Path $IndividualFolder
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Stop-MSTeams
|
||||||
|
Remove-MSTeamsCacheDirectory
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user