Coping With the Odd SfBO PowerShell Module
As I have noted before, Teams suffers from having two PowerShell modules. The Skype for Business Online module will eventually go away, but only when Microsoft retires Skype for Business Online in July 2021. Until then, I fear we must cope with the capricious nature of the module.
One of the most irritating aspects of the Skype for Business Online module is its inability to keep a session active for longer than an hour. I have no idea why Microsoft let this situation persist for so long, especially for a cloud service, but at least they have now released the Enable-CsOnlineSessionForReconnection cmdlet to paper over the problem. If you run the cmdlet in a session connected to Skype for Business Online, the session won’t time out and refuse to reconnect as once was the case. Instead, the behavior is slightly better and the session should reconnect, just like any well-mannered PowerShell session should.
Why Not Fix the Underlying Problem?
Of course, the immediate question that comes to mind is why this cmdlet is necessary at all. Why, for instance, didn’t Microsoft fix the underlining problem in the New-CsOnlineSession cmdlet so that once a session is established with the Skype for Business Online endpoint, it stays stable and usable for as long as is needed?
I suspect that the answer is that Microsoft didn’t want to open up a can of worms that might lurk in New-CsOnlineSession and decided instead to patch the problem with Enable-CsOnlineSessionForReconnection, the logic being that they didn’t want to invest any more engineering effort than necessary in a module that will soon be defunct. The rationale is understandable, even if it is also irritating.
Applying the Fix
In any case, to take advantage of the fix, download and install the latest version of the Skype for Business Online module (another irritation is that the new module has the same 184.108.40.206 version number as the previous version, perhaps yet another indication of the quick fix solution we see here). You can then insert the cmdlet in your connection scripts. I use a simple function in my PowerShell profile to connect to Skype for Business Online, which I have updated to make sure that Enable-CsOnlineSessionForReconnection is used every time I connect to the endpoint.
$userCredential = $O365Cred
$sfbSession = New-CsOnlineSession -Credential $O365Cred
Microsoft has published some documentation explaining that once the cmdlet is run, you should see that a Skype for Business Online PowerShell session reconnects after 60 minutes. Testing shows that the reconnection is automatic, and I haven’t experienced any issues, but given the size of Office 365 and the variety of configurations people run under, no guarantee is given that it will work as smoothly in your environment. Always test before deploying anything!
Coping with the oddities and mysteries of Office 365 is our specialty. Or at least we’re used to handling this kind of stuff. Which is why we pack the Office 365 for IT Pros eBook full of information like this.