question

MikeV-8521 avatar image
0 Votes"
MikeV-8521 asked ·

Powershell script skypeforbusiness connector disconnect issues

Hi,
Not sure if I'm posting in the right area, but here goes.
We recently built some call queues on MS Teams and one of the requirements is to obtain real time stats on how many calls are in the queue as well as how many agents are opted in. Although this is not officially supported, it is possible by creating an online session using the SBF connector or MicrosoftTeams connect and running the Get-CSCallQueue command.

I have this working via a powershell script which outputs the results as an html files. I can tell my users to run it on demand, but it takes a couple of minutes to execute so my thought is to have it run continously (either as a service, a scheduled task, or just starting it and letting it loop using while ($true) and continually refreshing the html file which also has the auto refresh flag set.

I found some limitations in having it run as a scheduled task, so I opted to have it run as a service. What I am finding is that it can run well for several iterations, up to a day or so, but at some point it will lose the connection to the 'remote server' and simply break. Sometimes I find it prompting for credentials (the same prompt you get after the one hour timeout), sometimes it just exits with an error like 'Starting a command on the remote server failed with the following error message....'

I have tried to build in some error handling to get around these issues:

  • I added commands to check the PSSession state and only run the Get-CSCallQueue commands when it is 'opened', or reconnect the session otherwise

  • I simply end the session and reconnect the session at the start of each loop

  • I added -erroraction continue to each get-csallqueue command in the script, my thinking is that it will simply reach the end of the loop and start over after reconnecting..

Eventually though it just fails. If the command fails and it is promting for creds I think it gets stuck there..

I think my approach to this may be all wrong, looking for ideas on how to get it to run continuously without breaking.

Thanks



office-teams-app-dev
· 1
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@MikeV-8521,
As we are mainly responsible for general issue of Teams, your requirement related to script is not in our scope. I will change office-teams-windows-itpro tag to office-teams-app-dev tag. Thanks for your understanding.

0 Votes 0 ·

1 Answer

KartheekRaparthy-6860 avatar image
0 Votes"
KartheekRaparthy-6860 answered ·

Hi @MikeV-8521

Please use below steps to fix your issue.
1)Latest power shell module of teams having skype for business connecter features. So install latest updated teams module.
2)connect teams module using below method
$username = "<username>"
$passwd = "<password>"

$secpasswd = ConvertTo-SecureString -String $passwd -AsPlainText -Force
$cred = New-Object Management.Automation.PSCredential ($username, $secpasswd)
Connect-MicrosoftTeams -Credential $cred
3)please go through these links. link1 Link2


·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.