fix(Stop-MSTeams): nom du processus Teams classic

Corrige le nom du processus de Teams Classic et base le chemin à partir du variable d'environnement $env:USERPROFILE
This commit is contained in:
Simon404 2024-02-12 20:00:00 +01:00
parent c5f839c176
commit 23e4bb00f3
1 changed files with 7 additions and 7 deletions

14
Clear-MSTeamsCache.ps1 Executable file → Normal file
View File

@ -18,18 +18,18 @@
Aucun
.NOTES
Version: 0.2
Version: 0.2.1
Author: Simon404
Creation Date: 2024-01-20
Creation Date: 2024-02-12
Purpose/Change: Script interactif avec vérification de l'existence du process de MS Teams (ancien et nouveau)
.EXAMPLE
Clear-MSTeamsCache.ps1
#>
#---------------------------------------------------------[Initialisations]----------------------------------------
#TODO: ajout CmdLet pour prise arguments
[CmdletBinding()]
Param (
[Parameter(Mandatory=$true,Position = 0)]
@ -37,10 +37,9 @@ Clear-MSTeamsCache.ps1
)
$MSTeamsNewProcessName = 'ms-teams'
$MSTeamsClassicProcessName = 'Microsoft Teams'
$CompanyName = "Microsoft Corporation"
$MSTeamsClassicProcessName = 'Teams'
$BasePath = "C:\Users\"
$BasePath = $env:USERPROFILE | SplitPath -Parent
$AppDataMSTeamsRoamingFolder = Join-Path -Path $BasePath -ChildPath "$SamAccountName\AppData\Roaming\Teams"
$AppDataMSTeamsRoamingSubFolder = Join-Path -Path $BasePath -ChildPath "$SamAccountName\AppData\Roaming\Microsoft\Teams"
$AppDataAADPackageFolder = Join-Path -Path $BasePath -ChildPath "$SamAccountName\AppData\Local\Packages\Microsoft.AAD.BrokerPlugin_cw5n1h2txyewy"
@ -52,9 +51,10 @@ $FoldersToDelete = @($AppDataMSTeamsRoamingFolder,$AppDataMSTeamsRoamingSubFolde
# Fermeture forcée du process MS Teams (Classic ou New)
function Stop-MSTeams {
$MSTeamsProcessList = Get-Process | Where-Object {(($_.ProcessName -eq "$MSTeamsClassicProcessName") -or ($_.ProcessName -eq "$MSTeamsNewProcessName"))} | Select-Object -ExpandProperty ProcessName
$MSTeamsProcessList = Get-Process | Where-Object {(($_.ProcessName -eq "$MSTeamsClassicProcessName") -or ($_.ProcessName -eq "$MSTeamsNewProcessName") -and ($_.Company -eq "Microsoft Corporation"))} | Select-Object -ExpandProperty ProcessName
if ($MSTeamsProcessList) {
foreach ($MSTeamsProcessName in $MSTeamsProcessList) {
Write-Host -Object "Fermeture de $MSTeamsProcessName"
Stop-Process -Force -Name $MSTeamsProcessName
}
}