PSADT To Detect Active MS Teams Call

I have the following script in my PSADT whereby I only want the script to work if users are not in an active Zoom or MS Teams call. The script stops working as expected when a user is on an active zoom call however cannot get this to work when in an active teams call. The script stops working when it detects that the teams app is open in the background and not in a call like zoom.

 ## Test if Zoom, Teams or Skype meetings are active
        Write-log "Check for active Zoom or Teams call"
        If (get-process | where {$_.Name -match "zoom$|teams$"}){
            If (((Get-NetUDPEndpoint -OwningProcess (get-process | where {$_.Name -match "zoom$|teams$"}).Id -ErrorAction SilentlyContinue | Where {$_.LocalAddress -ne '127.0.0.1'} | measure).count) -gt 0) {
                Write-log "Active Zoom or Teams call detected. Exiting script and trying again on next schedule"
                exit-script -ExitCode 1618
            }
        }

What am I doing wrong?

When you crosspost the same question at the same time to different forums you should at least post links to the other forums along with your question to avoid people willing to help you making their work twice or more.

Thanks