I recently ran into an issue with my lab trying to connect to Skype for Business Online PowerShell (SkypeOnlineConnector) which took me a little while to figure out. After launching PowerShell and importing the SkypeOnlineConnector module, I got the “Unable to connect to the remote server” error when running the New-CsOnlineSession command to authenticate using Modern Authentication:
$Session = New-CsOnlineSession -UserName <Admin Username>
Rather than launching the Modern Auth credential prompt as I was expecting the command instead threw that error immediately.
Now, what I had forgotten is that I had previously configured my lab with an on-premises Skype for Business Server deployment I have since deprovisioned, but I had not updated the public DNS records to point to Skype for Business Online. Because of this, and because I was using an admin account username with a custom domain, the module could not work out where to connect in order to authenticate. It’s worth noting though that this issue would affect you in exactly the same way if you are in a hybrid environment with your DNS records pointed to your Skype for Business Server on-premises deployment.
What I eventually remembered is that in this scenario, where for your SIP/username domain is not pointed at Office 365, you need to specify the OverrideAdminDomain parameter to direct the session to connect to your Office 365 Tenant.
$Session = New-CsOnlineSession -UserName <Admin Username> -OverrideAdminDomain <Tenant Name>.onmicrosoft.com
When I ran this command I was prompted for my Office 365 Admin password as expected.
I was then able to complete my authentication, import my session and launch Skype for Business Online PowerShell as expected.