Added Teams application process monitoring

pull/8/head
Danny de Vries 4 years ago
parent 16a9be2362
commit 624810fc27

@ -45,14 +45,15 @@ If($null -ne $SetStatus){
break break
} }
# Clear the status variable at the start
$CurrentStatus = ""
# Start monitoring the Teams logfile when no parameter is used to run the script # Start monitoring the Teams logfile when no parameter is used to run the script
DO { DO {
# Get Teams Logfile and last icon overlay status # Get Teams Logfile and last icon overlay status
$TeamsStatus = Get-Content -Path "C:\Users\$UserName\AppData\Roaming\Microsoft\Teams\logs.txt" -Tail 100 | Select-String -Pattern ` $TeamsStatus = Get-Content -Path "C:\Users\$UserName\AppData\Roaming\Microsoft\Teams\logs.txt" -Tail 100 | Select-String -Pattern `
'Setting the taskbar overlay icon -',` 'Setting the taskbar overlay icon -',`
'StatusIndicatorStateService: Added',` 'StatusIndicatorStateService: Added' | Select-Object -Last 1
'Main window is closing',`
'main window closed' | Select-Object -Last 1
# Get Teams Logfile and last app update deamon status # Get Teams Logfile and last app update deamon status
$TeamsActivity = Get-Content -Path "C:\Users\$UserName\AppData\Roaming\Microsoft\Teams\logs.txt" -Tail 100 | Select-String -Pattern ` $TeamsActivity = Get-Content -Path "C:\Users\$UserName\AppData\Roaming\Microsoft\Teams\logs.txt" -Tail 100 | Select-String -Pattern `
'Resuming daemon App updates',` 'Resuming daemon App updates',`
@ -60,7 +61,11 @@ $TeamsActivity = Get-Content -Path "C:\Users\$UserName\AppData\Roaming\Microsoft
'SfB:TeamsNoCall',` 'SfB:TeamsNoCall',`
'SfB:TeamsPendingCall',` 'SfB:TeamsPendingCall',`
'SfB:TeamsActiveCall' | Select-Object -Last 1 'SfB:TeamsActiveCall' | Select-Object -Last 1
# Get Teams application process
$TeamsProcess = Get-Process -Name Teams -ErrorAction SilentlyContinue
# Check if Teams is running and start monitoring the log if it is
If ($null -ne $TeamsProcess) {
If ($TeamsStatus -like "*Setting the taskbar overlay icon - Available*" -or ` If ($TeamsStatus -like "*Setting the taskbar overlay icon - Available*" -or `
$TeamsStatus -like "*StatusIndicatorStateService: Added Available*") { $TeamsStatus -like "*StatusIndicatorStateService: Added Available*") {
$Status = "Available" $Status = "Available"
@ -89,7 +94,9 @@ ElseIf ($TeamsStatus -like "*Setting the taskbar overlay icon - In a meeting*" -
$Status = "In a meeting" $Status = "In a meeting"
Write-Host $Status Write-Host $Status
} }
ElseIf ($TeamsStatus -like "*ain window*") { }
# Set status to Offline when the Teams application is not running
Else {
$Status = "Offline" $Status = "Offline"
Write-Host $Status Write-Host $Status
} }

Loading…
Cancel
Save