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:
parent
c5f839c176
commit
23e4bb00f3
14
Clear-MSTeamsCache.ps1
Executable file → Normal file
14
Clear-MSTeamsCache.ps1
Executable file → Normal file
@ -18,18 +18,18 @@
|
|||||||
Aucun
|
Aucun
|
||||||
|
|
||||||
.NOTES
|
.NOTES
|
||||||
Version: 0.2
|
Version: 0.2.1
|
||||||
Author: Simon404
|
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)
|
Purpose/Change: Script interactif avec vérification de l'existence du process de MS Teams (ancien et nouveau)
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
Clear-MSTeamsCache.ps1
|
Clear-MSTeamsCache.ps1
|
||||||
#>
|
#>
|
||||||
|
|
||||||
|
|
||||||
#---------------------------------------------------------[Initialisations]----------------------------------------
|
#---------------------------------------------------------[Initialisations]----------------------------------------
|
||||||
|
|
||||||
#TODO: ajout CmdLet pour prise arguments
|
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
Param (
|
Param (
|
||||||
[Parameter(Mandatory=$true,Position = 0)]
|
[Parameter(Mandatory=$true,Position = 0)]
|
||||||
@ -37,10 +37,9 @@ Clear-MSTeamsCache.ps1
|
|||||||
)
|
)
|
||||||
|
|
||||||
$MSTeamsNewProcessName = 'ms-teams'
|
$MSTeamsNewProcessName = 'ms-teams'
|
||||||
$MSTeamsClassicProcessName = 'Microsoft Teams'
|
$MSTeamsClassicProcessName = 'Teams'
|
||||||
$CompanyName = "Microsoft Corporation"
|
|
||||||
|
|
||||||
$BasePath = "C:\Users\"
|
$BasePath = $env:USERPROFILE | SplitPath -Parent
|
||||||
$AppDataMSTeamsRoamingFolder = Join-Path -Path $BasePath -ChildPath "$SamAccountName\AppData\Roaming\Teams"
|
$AppDataMSTeamsRoamingFolder = Join-Path -Path $BasePath -ChildPath "$SamAccountName\AppData\Roaming\Teams"
|
||||||
$AppDataMSTeamsRoamingSubFolder = Join-Path -Path $BasePath -ChildPath "$SamAccountName\AppData\Roaming\Microsoft\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"
|
$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)
|
# Fermeture forcée du process MS Teams (Classic ou New)
|
||||||
function Stop-MSTeams {
|
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) {
|
if ($MSTeamsProcessList) {
|
||||||
foreach ($MSTeamsProcessName in $MSTeamsProcessList) {
|
foreach ($MSTeamsProcessName in $MSTeamsProcessList) {
|
||||||
|
Write-Host -Object "Fermeture de $MSTeamsProcessName"
|
||||||
Stop-Process -Force -Name $MSTeamsProcessName
|
Stop-Process -Force -Name $MSTeamsProcessName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user