From 23e4bb00f324b918583ca9e467b8218da9cd18be Mon Sep 17 00:00:00 2001 From: Simon404 Date: Mon, 12 Feb 2024 20:00:00 +0100 Subject: [PATCH] fix(Stop-MSTeams): nom du processus Teams classic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Corrige le nom du processus de Teams Classic et base le chemin à partir du variable d'environnement $env:USERPROFILE --- Clear-MSTeamsCache.ps1 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) mode change 100755 => 100644 Clear-MSTeamsCache.ps1 diff --git a/Clear-MSTeamsCache.ps1 b/Clear-MSTeamsCache.ps1 old mode 100755 new mode 100644 index ec84a8f..703327c --- a/Clear-MSTeamsCache.ps1 +++ b/Clear-MSTeamsCache.ps1 @@ -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 } }