# Auto-Answer Teams call with Video and PowerShell

•
•
•
•
•
•

Today, while working with my esteemed colleague Stephen Jones, we were discussing a need for some of our customers to auto-answer Teams with a video call.  This has a lot of practical scenarios, such as judicial, hospital, and corrections facilities.

A similar feature was available in Skype for Business.  Currently, there’s not a corresponding feature for Teams (though it’s on the roadmap).

After kicking around a few ideas, this is what we came up with:

$Log = "$($env:APPDATA)\Microsoft\Teams\logs.txt" While ( Get-Content -Tail 100$Log | ? { $_ -notmatch "TeamsPendingCall" } ) { [array]$teamsarray = (get-process *teams*).Id
foreach ($obj in$teamsarray)
{
$wshell = New-Object -ComObject wscript.shell$Result = $wshell.AppActivate($obj)
$Result2 =$wshell.SendKeys('^+A')
$SleepTime = 20$i = 1
Foreach ($i in 1..$SleepTime)
{
Write-Progress -PercentComplete (($i /$SleepTime) * 100) -Activity "Waiting to check log file."; sleep -seconds 1; \$i++
}
}
}

Basically, it monitors the Teams log file for a “TeamsPendingCall” entry and then using the oldest-of-old-school methods, calling the VBScript WShell AppActivate method to make the Teams window active (though we don’t know which one, so we’re just gonna cycle through all of them) and then sending it the Ctrl+Shift+A hotkey sequence (the “Auto-answer a call with video” hotkey combo for Teams).

You can save this as a .PS1 and add it to a user start-up (since Teams needs to be running and signed in).  It’ not glamourous, and definitely not supported, but it is workable.

I’d love to hear comments on it!